src/Entity/Rule.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\RuleType;
  4. use App\Enum\RuleRateType;
  5. use App\Enum\RuleMultiplier;
  6. use App\Repository\RuleRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Timestampable\Traits\TimestampableEntity;
  12. #[ORM\Entity(repositoryClassRuleRepository::class)]
  13. class Rule
  14. {
  15.     use TimestampableEntity;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $name null;
  22.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  23.     private ?string $description null;
  24.     #[ORM\Column(length255nullabletrue)]
  25.     private ?RuleType $type null;
  26.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  27.     private ?\DateTimeInterface $activeStartDate null;
  28.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  29.     private ?\DateTimeInterface $activeEndDate null;
  30.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  31.     private ?\DateTimeInterface $effectiveStartDate null;
  32.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  33.     private ?\DateTimeInterface $effectiveEndDate null;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     private ?string $inputType null;
  36.     #[ORM\Column(length255nullabletrue)]
  37.     private ?RuleMultiplier $multiplier null;
  38.     #[ORM\Column(length255nullabletrue)]
  39.     private ?RuleRateType $rateType null;
  40.     #[ORM\ManyToOne(inversedBy'rules')]
  41.     private ?NamedRelationship $namedRelationship null;
  42.     #[ORM\Column]
  43.     private ?bool $rollableOnReporting null;
  44.     #[ORM\OneToMany(mappedBy'rule'targetEntityRuleVersion::class)]
  45.     private Collection $ruleVersions;
  46.     #[ORM\OneToMany(mappedBy'rule'targetEntityRuleResult::class)]
  47.     private Collection $ruleResults;
  48.     #[ORM\ManyToMany(targetEntityPlan::class, mappedBy'rules')]
  49.     private Collection $plans;
  50.     public function __construct()
  51.     {
  52.         $this->ruleVersions = new ArrayCollection();
  53.         $this->ruleResults = new ArrayCollection();
  54.         $this->plans = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getName(): ?string
  61.     {
  62.         return $this->name;
  63.     }
  64.     public function setName(?string $name): self
  65.     {
  66.         $this->name $name;
  67.         return $this;
  68.     }
  69.     public function getDescription(): ?string
  70.     {
  71.         return $this->description;
  72.     }
  73.     public function setDescription(?string $description): self
  74.     {
  75.         $this->description $description;
  76.         return $this;
  77.     }
  78.     public function getType(): ?RuleType
  79.     {
  80.         return $this->type;
  81.     }
  82.     public function setType(?RuleType $type): self
  83.     {
  84.         $this->type $type;
  85.         return $this;
  86.     }
  87.     public function getActiveStartDate(): ?\DateTimeInterface
  88.     {
  89.         return $this->activeStartDate;
  90.     }
  91.     public function setActiveStartDate(?\DateTimeInterface $activeStartDate): self
  92.     {
  93.         $this->activeStartDate $activeStartDate;
  94.         return $this;
  95.     }
  96.     public function getActiveEndDate(): ?\DateTimeInterface
  97.     {
  98.         return $this->activeEndDate;
  99.     }
  100.     public function setActiveEndDate(?\DateTimeInterface $activeEndDate): self
  101.     {
  102.         $this->activeEndDate $activeEndDate;
  103.         return $this;
  104.     }
  105.     public function getEffectiveEndDate(): ?\DateTimeInterface
  106.     {
  107.         return $this->effectiveEndDate;
  108.     }
  109.     public function setEffectiveEndDate(?\DateTimeInterface $effectiveEndDate): self
  110.     {
  111.         $this->effectiveEndDate $effectiveEndDate;
  112.         return $this;
  113.     }
  114.     public function getInputType(): ?string
  115.     {
  116.         return $this->inputType;
  117.     }
  118.     public function setInputType(?string $inputType): self
  119.     {
  120.         $this->inputType $inputType;
  121.         return $this;
  122.     }
  123.     public function getMultiplier(): ?RuleMultiplier
  124.     {
  125.         return $this->multiplier;
  126.     }
  127.     public function setMultiplier(?RuleMultiplier $multiplier): self
  128.     {
  129.         $this->multiplier $multiplier;
  130.         return $this;
  131.     }
  132.     public function getRateType(): ?RuleRateType
  133.     {
  134.         return $this->rateType;
  135.     }
  136.     public function setRateType(?RuleRateType $rateType): self
  137.     {
  138.         $this->rateType $rateType;
  139.         return $this;
  140.     }
  141.     public function getNamedRelationship(): ?NamedRelationship
  142.     {
  143.         return $this->namedRelationship;
  144.     }
  145.     public function setNamedRelationship(?NamedRelationship $namedRelationship): self
  146.     {
  147.         $this->namedRelationship $namedRelationship;
  148.         return $this;
  149.     }
  150.     public function isRollableOnReporting(): ?bool
  151.     {
  152.         return $this->rollableOnReporting;
  153.     }
  154.     public function setRollableOnReporting(bool $rollableOnReporting): self
  155.     {
  156.         $this->rollableOnReporting $rollableOnReporting;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection<int, RuleVersion>
  161.      */
  162.     public function getRuleVersions(): Collection
  163.     {
  164.         return $this->ruleVersions;
  165.     }
  166.     public function addRuleVersion(RuleVersion $ruleVersion): self
  167.     {
  168.         if (!$this->ruleVersions->contains($ruleVersion)) {
  169.             $this->ruleVersions->add($ruleVersion);
  170.             $ruleVersion->setRule($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeRuleVersion(RuleVersion $ruleVersion): self
  175.     {
  176.         if ($this->ruleVersions->removeElement($ruleVersion)) {
  177.             // set the owning side to null (unless already changed)
  178.             if ($ruleVersion->getRule() === $this) {
  179.                 $ruleVersion->setRule(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return Collection<int, RuleResult>
  186.      */
  187.     public function getRuleResults(): Collection
  188.     {
  189.         return $this->ruleResults;
  190.     }
  191.     public function addRuleResult(RuleResult $ruleResult): static
  192.     {
  193.         if (!$this->ruleResults->contains($ruleResult)) {
  194.             $this->ruleResults->add($ruleResult);
  195.             $ruleResult->setRule($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeRuleResult(RuleResult $ruleResult): static
  200.     {
  201.         if ($this->ruleResults->removeElement($ruleResult)) {
  202.             // set the owning side to null (unless already changed)
  203.             if ($ruleResult->getRule() === $this) {
  204.                 $ruleResult->setRule(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Collection<int, Plan>
  211.      */
  212.     public function getPlans(): Collection
  213.     {
  214.         return $this->plans;
  215.     }
  216.     public function addPlan(Plan $plan): static
  217.     {
  218.         if (!$this->plans->contains($plan)) {
  219.             $this->plans->add($plan);
  220.             $plan->addRule($this);
  221.         }
  222.         return $this;
  223.     }
  224.     public function removePlan(Plan $plan): static
  225.     {
  226.         if ($this->plans->removeElement($plan)) {
  227.             $plan->removeRule($this);
  228.         }
  229.         return $this;
  230.     }
  231.     public function __toString(): string
  232.     {
  233.         return $this->getName();
  234.         return sprintf('%s - %s'$this->getName(), $this->getType()->title());
  235.     }
  236. }