diff --git a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php index d2fbe9560..52e895bec 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php +++ b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php @@ -11,11 +11,13 @@ declare(strict_types=1); namespace Chill\BudgetBundle\Entity; +use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use DateTime; use DateTimeImmutable; use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; +use Ramsey\Uuid\Type\Decimal; use Symfony\Component\Validator\Constraints as Assert; /** @@ -26,8 +28,6 @@ use Symfony\Component\Validator\Constraints as Assert; abstract class AbstractElement { /** - * @var decimal - * * @ORM\Column(name="amount", type="decimal", precision=10, scale=2) * @Assert\GreaterThan( * value=0 @@ -36,17 +36,14 @@ abstract class AbstractElement * message="The amount cannot be empty" * ) */ - private $amount; + private string $amount; /** - * @var string|null - * * @ORM\Column(name="comment", type="text", nullable=true) */ - private $comment; + private ?string $comment; /** - * @var DateTimeImmutable|null * * @ORM\Column(name="endDate", type="datetime_immutable", nullable=true) * @Assert\GreaterThan( @@ -54,82 +51,68 @@ abstract class AbstractElement * message="The budget element's end date must be after the start date" * ) */ - private $endDate; + private ?DateTimeImmutable $endDate; /** - * @var Person * @ORM\ManyToOne( * targetEntity="\Chill\PersonBundle\Entity\Person" * ) */ - private $person; + private ?Person $person = null; + + /** + * @ORM\ManyToOne( + * targetEntity="\Chill\PersonBundle\Entity\Household\Household" + * ) + */ + private ?Household $household = null; /** - * @var DateTimeImmutable * * @ORM\Column(name="startDate", type="datetime_immutable") * @Assert\Date */ - private $startDate; + private DateTimeImmutable $startDate; /** - * @var string * * @ORM\Column(name="type", type="string", length=255) */ - private $type; + private string $type; - /** - * Get amount. - * - * @return float - */ - public function getAmount() + /**Getters and Setters */ + + public function getAmount(): float { return (float) $this->amount; } - /** - * Get comment. - * - * @return string|null - */ - public function getComment() + public function getComment(): ?string { return $this->comment; } - /** - * Get endDate. - * - * @return DateTimeImmutable|null - */ - public function getEndDate() + public function getEndDate(): ?DateTimeImmutable { return $this->endDate; } - public function getPerson(): Person + public function getPerson(): ?Person { return $this->person; } - /** - * Get startDate. - * - * @return DateTimeImmutable - */ - public function getStartDate() + public function getHousehold(): ?Household + { + return $this->household; + } + + public function getStartDate(): DateTimeImmutable { return $this->startDate; } - /** - * Get type. - * - * @return string - */ - public function getType() + public function getType(): string { return $this->type; } @@ -143,40 +126,21 @@ abstract class AbstractElement abstract public function isResource(): bool; - /** - * Set amount. - * - * @param string $amount - * - * @return AbstractElement - */ - public function setAmount($amount) + public function setAmount(string $amount): self { $this->amount = $amount; return $this; } - /** - * Set comment. - * - * @param string|null $comment - * - * @return AbstractElement - */ - public function setComment($comment = null) + public function setComment(?string $comment = null): self { $this->comment = $comment; return $this; } - /** - * Set endDate. - * - * @return AbstractElement - */ - public function setEndDate(?DateTimeInterface $endDate = null) + public function setEndDate(?DateTimeInterface $endDate = null): self { if ($endDate instanceof DateTime) { $this->endDate = DateTimeImmutable::createFromMutable($endDate); @@ -189,19 +153,21 @@ abstract class AbstractElement return $this; } - public function setPerson(Person $person) + public function setPerson(Person $person): self { $this->person = $person; return $this; } - /** - * Set startDate. - * - * @return AbstractElement - */ - public function setStartDate(DateTimeInterface $startDate) + public function setHousehold(Household $household): self + { + $this->household = $household; + + return $this; + } + + public function setStartDate(DateTimeInterface $startDate): self { if ($startDate instanceof DateTime) { $this->startDate = DateTimeImmutable::createFromMutable($startDate); @@ -214,14 +180,7 @@ abstract class AbstractElement return $this; } - /** - * Set type. - * - * @param string $type - * - * @return AbstractElement - */ - public function setType($type) + public function setType(string $type): self { $this->type = $type;