mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 04:23:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -16,8 +16,6 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Validator\Constraints\Relationship\RelationshipNoDuplicate;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\ORM\Mapping\DiscriminatorColumn;
|
||||
use RuntimeException;
|
||||
@@ -27,11 +25,15 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_relationships")
|
||||
*
|
||||
* @DiscriminatorColumn(name="relation_id", type="integer")
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "relationship": Relationship::class
|
||||
* })
|
||||
*
|
||||
* @RelationshipNoDuplicate
|
||||
*/
|
||||
class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
@@ -39,52 +41,67 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*/
|
||||
private ?DateTimeImmutable $createdAt = null;
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?Person $fromPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Relation::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false, name="relation_id", referencedColumnName="id")
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?Relation $relation = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*
|
||||
* @Assert\Type(
|
||||
* type="bool",
|
||||
* message="This must be of type boolean"
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private bool $reverse;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
private ?Person $toPerson = null;
|
||||
@@ -92,14 +109,14 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true)
|
||||
*/
|
||||
private ?DateTimeImmutable $updatedAt = null;
|
||||
private ?\DateTimeImmutable $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*/
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
public function getCreatedAt(): ?DateTimeImmutable
|
||||
public function getCreatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
@@ -130,7 +147,7 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
public function getOpposite(Person $counterpart): Person
|
||||
{
|
||||
if ($this->fromPerson !== $counterpart && $this->toPerson !== $counterpart) {
|
||||
throw new RuntimeException('the counterpart is neither the from nor to person for this relationship');
|
||||
throw new \RuntimeException('the counterpart is neither the from nor to person for this relationship');
|
||||
}
|
||||
|
||||
if ($this->fromPerson === $counterpart) {
|
||||
@@ -155,7 +172,7 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->toPerson;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?DateTimeImmutable
|
||||
public function getUpdatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
@@ -165,7 +182,7 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function setCreatedAt(DateTimeInterface $createdAt): self
|
||||
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
@@ -207,7 +224,7 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(?DateTimeInterface $updatedAt): self
|
||||
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
|
Reference in New Issue
Block a user