cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,21 +1,40 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Entity\SocialWork;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity
* @ORM\Table(name="chill_person_social_issue")
* @DiscriminatorMap(typeProperty="type", mapping={
* "social_issue"=SocialIssue::class
* "social_issue": SocialIssue::class
* })
*/
class SocialIssue
{
/**
* @ORM\OneToMany(targetEntity=SocialIssue::class, mappedBy="parent")
*/
private $children;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $desactivationDate;
/**
* @ORM\Id
* @ORM\GeneratedValue
@@ -29,14 +48,9 @@ class SocialIssue
private $parent;
/**
* @ORM\OneToMany(targetEntity=SocialIssue::class, mappedBy="parent")
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="issue")
*/
private $children;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $desactivationDate;
private $socialActions;
/**
* @ORM\Column(type="json")
@@ -44,47 +58,12 @@ class SocialIssue
*/
private $title = [];
/**
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="issue")
*/
private $socialActions;
public function __construct()
{
$this->children = new ArrayCollection();
$this->socialActions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getParent(): ?self
{
return $this->parent;
}
public function hasParent(): bool
{
return $this->parent !== null;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection|self[]
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChild(self $child): self
{
if (!$this->children->contains($child)) {
@@ -95,18 +74,64 @@ class SocialIssue
return $this;
}
public function removeChild(self $child): self
public function addSocialAction(SocialAction $socialAction): self
{
if ($this->children->removeElement($child)) {
// set the owning side to null (unless already changed)
if ($child->getParent() === $this) {
$child->setParent(null);
}
if (!$this->socialActions->contains($socialAction)) {
$this->socialActions[] = $socialAction;
$socialAction->setSocialIssue($this);
}
return $this;
}
/**
* In a SocialIssues's collection, find the elements which are an ancestor of
* other elements.
*
* Removing those elements of the Collection (which is not done by this method)
* will ensure that only the most descendent elements are present in the collection,
* (any ancestor of another element are present).
*
* @param Collection|SocialIssue[] $socialIssues
*
* @return Collection|SocialIssue[]
*/
public static function findAncestorSocialIssues(Collection $socialIssues): Collection
{
$ancestors = new ArrayCollection();
foreach ($socialIssues as $candidateChild) {
if ($ancestors->contains($candidateChild)) {
continue;
}
foreach ($socialIssues as $candidateParent) {
if ($ancestors->contains($candidateParent)) {
continue;
}
if ($candidateChild->isDescendantOf($candidateParent)) {
$ancestors->add($candidateParent);
}
}
}
return $ancestors;
}
/**
* @return Collection|self[]
*/
public function getChildren(): Collection
{
return $this->children;
}
public function getDesactivationDate(): ?DateTimeInterface
{
return $this->desactivationDate;
}
/**
* @return Collection|self[] All the descendants (children, children of children, ...)
*/
@@ -115,10 +140,11 @@ class SocialIssue
$descendants = new ArrayCollection();
foreach ($this->getChildren() as $child) {
if(! $descendants->contains($child)) {
if (!$descendants->contains($child)) {
$descendants->add($child);
foreach($child->getDescendants() as $descendantsOfChild) {
if(! $descendants->contains($descendantsOfChild)) {
foreach ($child->getDescendants() as $descendantsOfChild) {
if (!$descendants->contains($descendantsOfChild)) {
$descendants->add($descendantsOfChild);
}
}
@@ -128,6 +154,24 @@ class SocialIssue
return $descendants;
}
/**
* @return Collection|SocialAction[] All the descendant social actions of the entity
*/
public function getDescendantsSocialActions(): Collection
{
$descendantsSocialActions = new ArrayCollection();
foreach ($this->getSocialActions() as $socialAction) {
foreach ($socialAction->getDescendantsWithThis() as $descendant) {
if (!$descendantsSocialActions->contains($descendant)) {
$descendantsSocialActions->add($descendant);
}
}
}
return $descendantsSocialActions;
}
/**
* @return Collection|self[] All the descendants with the current entity (this)
*/
@@ -135,36 +179,40 @@ class SocialIssue
{
$descendants = $this->getDescendants();
if(! $descendants->contains($this)) {
if (!$descendants->contains($this)) {
$descendants->add($this);
}
return $descendants;
}
public function getDesactivationDate(): ?\DateTimeInterface
public function getId(): ?int
{
return $this->desactivationDate;
return $this->id;
}
public function setDesactivationDate(?\DateTimeInterface $desactivationDate): self
public function getParent(): ?self
{
$this->desactivationDate = $desactivationDate;
return $this;
return $this->parent;
}
public function getTitle(): array
/**
* @return Collection|SocialAction[] All the descendant social actions of all
* the descendants of the entity
*/
public function getRecursiveSocialActions(): Collection
{
return $this->title;
}
$recursiveSocialActions = new ArrayCollection();
public function setTitle(array $title): self
{
$this->title = $title;
foreach ($this->getDescendantsWithThis() as $socialIssue) {
foreach ($socialIssue->getDescendantsSocialActions() as $descendant) {
if (!$recursiveSocialActions->contains($descendant)) {
$recursiveSocialActions->add($descendant);
}
}
}
return $this;
return $recursiveSocialActions;
}
/**
@@ -175,11 +223,40 @@ class SocialIssue
return $this->socialActions;
}
public function addSocialAction(SocialAction $socialAction): self
public function getTitle(): array
{
if (!$this->socialActions->contains($socialAction)) {
$this->socialActions[] = $socialAction;
$socialAction->setSocialIssue($this);
return $this->title;
}
public function hasParent(): bool
{
return null !== $this->parent;
}
/**
* Recursive method which return true if the current $issue is a descendant
* of the $issue given in parameter.
*/
public function isDescendantOf(SocialIssue $issue): bool
{
if (!$this->hasParent()) {
return false;
}
if ($this->getParent() === $issue) {
return true;
}
return $this->getParent()->isDescendantOf($issue);
}
public function removeChild(self $child): self
{
if ($this->children->removeElement($child)) {
// set the owning side to null (unless already changed)
if ($child->getParent() === $this) {
$child->setParent(null);
}
}
return $this;
@@ -197,93 +274,24 @@ class SocialIssue
return $this;
}
/**
* @return Collection|SocialAction[] All the descendant social actions of the entity
*/
public function getDescendantsSocialActions(): Collection
public function setDesactivationDate(?DateTimeInterface $desactivationDate): self
{
$descendantsSocialActions = new ArrayCollection();
$this->desactivationDate = $desactivationDate;
foreach ($this->getSocialActions() as $socialAction) {
foreach ($socialAction->getDescendantsWithThis() as $descendant) {
if(! $descendantsSocialActions->contains($descendant)) {
$descendantsSocialActions->add($descendant);
}
}
}
return $descendantsSocialActions;
return $this;
}
/**
* @return Collection|SocialAction[] All the descendant social actions of all
* the descendants of the entity
*/
public function getRecursiveSocialActions(): Collection
public function setParent(?self $parent): self
{
$recursiveSocialActions = new ArrayCollection();
$this->parent = $parent;
foreach ($this->getDescendantsWithThis() as $socialIssue) {
foreach ($socialIssue->getDescendantsSocialActions() as $descendant) {
if(! $recursiveSocialActions->contains($descendant)) {
$recursiveSocialActions->add($descendant);
}
}
}
return $recursiveSocialActions;
return $this;
}
/**
* Recursive method which return true if the current $issue is a descendant
* of the $issue given in parameter.
*
* @param SocialIssue $issue
* @return bool
*/
public function isDescendantOf(SocialIssue $issue): bool
public function setTitle(array $title): self
{
if (!$this->hasParent()) {
return false;
}
$this->title = $title;
if ($this->getParent() === $issue) {
return true;
}
return $this->getParent()->isDescendantOf($issue);
}
/**
* In a SocialIssues's collection, find the elements which are an ancestor of
* other elements.
*
* Removing those elements of the Collection (which is not done by this method)
* will ensure that only the most descendent elements are present in the collection,
* (any ancestor of another element are present).
*
* @param Collection|SocialIssue[] $socialIssues
* @return Collection|SocialIssue[]
*/
public static function findAncestorSocialIssues(Collection $socialIssues): Collection
{
$ancestors = new ArrayCollection();
foreach ($socialIssues as $candidateChild) {
if ($ancestors->contains($candidateChild)) {
continue;
}
foreach ($socialIssues as $candidateParent) {
if ($ancestors->contains($candidateParent)) {
continue;
}
if ($candidateChild->isDescendantOf($candidateParent)) {
$ancestors->add($candidateParent);
}
}
}
return $ancestors;
return $this;
}
}