src/Entity/RuleVersion.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use App\Repository\RuleVersionRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. #[ORM\Entity(repositoryClassRuleVersionRepository::class)]
  10. class RuleVersion
  11. {
  12.     use TimestampableEntity;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\ManyToOne(inversedBy'ruleVersions')]
  18.     #[ORM\JoinColumn(nullablefalse)]
  19.     private ?Rule $rule null;
  20.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  21.     private ?\DateTimeInterface $effectiveStartDate null;
  22.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  23.     private ?\DateTimeInterface $effectiveEndDate null;
  24.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  25.     private ?\DateTimeInterface $activeStartDate null;
  26.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  27.     private ?\DateTimeInterface $activeEndDate null;
  28.     #[ORM\ManyToOne(inversedBy'ruleVersions'fetch'EAGER')]
  29.     private ?AttainmentMeasure $attainmentMeasure null;
  30.     #[ORM\Column]
  31.     private ?bool $isMaster false;
  32.     #[ORM\OneToMany(mappedBy'ruleVersion'targetEntityRuleCondition::class, orphanRemovaltrue)]
  33.     private Collection $ruleConditions;
  34.     public function __construct()
  35.     {
  36.         $this->ruleConditions = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getRule(): ?Rule
  43.     {
  44.         return $this->rule;
  45.     }
  46.     public function setRule(?Rule $rule): self
  47.     {
  48.         $this->rule $rule;
  49.         return $this;
  50.     }
  51.     public function getEffectiveStartDate(): ?\DateTimeInterface
  52.     {
  53.         return $this->effectiveStartDate;
  54.     }
  55.     public function setEffectiveStartDate(?\DateTimeInterface $effectiveStartDate): static
  56.     {
  57.         $this->effectiveStartDate $effectiveStartDate;
  58.         return $this;
  59.     }
  60.     public function getEffectiveEndDate(): ?\DateTimeInterface
  61.     {
  62.         return $this->effectiveEndDate;
  63.     }
  64.     public function setEffectiveEndDate(?\DateTimeInterface $effectiveEndDate): static
  65.     {
  66.         $this->effectiveEndDate $effectiveEndDate;
  67.         return $this;
  68.     }
  69.     public function getActiveStartDate(): ?\DateTimeInterface
  70.     {
  71.         return $this->activeStartDate;
  72.     }
  73.     public function setActiveStartDate(?\DateTimeInterface $activeStartDate): self
  74.     {
  75.         $this->activeStartDate $activeStartDate;
  76.         return $this;
  77.     }
  78.     public function getActiveEndDate(): ?\DateTimeInterface
  79.     {
  80.         return $this->activeEndDate;
  81.     }
  82.     public function setActiveEndDate(?\DateTimeInterface $activeEndDate): self
  83.     {
  84.         $this->activeEndDate $activeEndDate;
  85.         return $this;
  86.     }
  87.     public function getAttainmentMeasure(): ?AttainmentMeasure
  88.     {
  89.         return $this->attainmentMeasure;
  90.     }
  91.     public function setAttainmentMeasure(?AttainmentMeasure $attainmentMeasure): self
  92.     {
  93.         $this->attainmentMeasure $attainmentMeasure;
  94.         return $this;
  95.     }
  96.     public function isIsMaster(): ?bool
  97.     {
  98.         return $this->isMaster;
  99.     }
  100.     public function setIsMaster(bool $isMaster): self
  101.     {
  102.         $this->isMaster $isMaster;
  103.         return $this;
  104.     }
  105.     /**
  106.      * @return Collection<int, RuleCondition>
  107.      */
  108.     public function getRuleConditions(): Collection
  109.     {
  110.         return $this->ruleConditions;
  111.     }
  112.     public function addRuleCondition(RuleCondition $ruleCondition): self
  113.     {
  114.         if (!$this->ruleConditions->contains($ruleCondition)) {
  115.             $this->ruleConditions->add($ruleCondition);
  116.             $ruleCondition->setRuleVersion($this);
  117.         }
  118.         return $this;
  119.     }
  120.     public function removeRuleCondition(RuleCondition $ruleCondition): self
  121.     {
  122.         if ($this->ruleConditions->removeElement($ruleCondition)) {
  123.             // set the owning side to null (unless already changed)
  124.             if ($ruleCondition->getRuleVersion() === $this) {
  125.                 $ruleCondition->setRuleVersion(null);
  126.             }
  127.         }
  128.         return $this;
  129.     }
  130.     public function __toString(): string
  131.     {
  132.         $endDate $this->effectiveEndDate $this->effectiveEndDate->format('Y-m-d') : 'EOD';
  133.         return sprintf('[%s] %s (%s - %s)'$this->getRule()->getId(), $this->getRule()->getName(), $this->getEffectiveStartDate()->format('m/d/Y'), $endDate);
  134.     }
  135. }