src/Entity/AttainmentMeasure.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\AttainmentPeriod;
  4. use App\Repository\AttainmentMeasureRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. #[ORM\Entity(repositoryClassAttainmentMeasureRepository::class)]
  10. class AttainmentMeasure
  11. {
  12.     use TimestampableEntity;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\ManyToMany(targetEntityCreditType::class, inversedBy'attainmentMeasures'cascade: ['persist''remove'])]
  20.     private Collection $creditTypes;
  21.     #[ORM\Column(length255nullabletrue)]
  22.     private ?string $description null;
  23.     #[ORM\Column(length255nullabletrue)]
  24.     private ?AttainmentPeriod $period null;
  25.     #[ORM\ManyToOne(inversedBy'attainmentMeasures')]
  26.     private ?Year $year null;
  27.     #[ORM\OneToMany(mappedBy'attainmentMeasure'targetEntityRuleVersion::class)]
  28.     private Collection $ruleVersions;
  29.     #[ORM\OneToMany(mappedBy'attainmentMeasure'targetEntityRuleResult::class)]
  30.     private Collection $ruleResults;
  31.     public function __construct()
  32.     {
  33.         $this->creditTypes = new ArrayCollection();
  34.         $this->ruleVersions = new ArrayCollection();
  35.         $this->ruleResults = new ArrayCollection();
  36.     }
  37.     public function getId(): ?int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function getName(): ?string
  42.     {
  43.         return $this->name;
  44.     }
  45.     public function setName(string $name): self
  46.     {
  47.         $this->name $name;
  48.         return $this;
  49.     }
  50.     /**
  51.      * @return Collection<int, CreditType>
  52.      */
  53.     public function getCreditTypes(): Collection
  54.     {
  55.         return $this->creditTypes;
  56.     }
  57.     public function addCreditType(CreditType $creditType): self
  58.     {
  59.         if (!$this->creditTypes->contains($creditType)) {
  60.             $this->creditTypes->add($creditType);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeCreditType(CreditType $creditType): self
  65.     {
  66.         $this->creditTypes->removeElement($creditType);
  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 getPeriod(): ?AttainmentPeriod
  79.     {
  80.         return $this->period;
  81.     }
  82.     public function setPeriod(?AttainmentPeriod $period): self
  83.     {
  84.         $this->period $period;
  85.         return $this;
  86.     }
  87.     public function __toString()
  88.     {
  89.         return $this->getName();
  90.     }
  91.     public function getYear(): ?Year
  92.     {
  93.         return $this->year;
  94.     }
  95.     public function setYear(?Year $year): self
  96.     {
  97.         $this->year $year;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection<int, RuleVersion>
  102.      */
  103.     public function getRuleVersions(): Collection
  104.     {
  105.         return $this->ruleVersions;
  106.     }
  107.     public function addRuleVersion(RuleVersion $ruleVersion): self
  108.     {
  109.         if (!$this->ruleVersions->contains($ruleVersion)) {
  110.             $this->ruleVersions->add($ruleVersion);
  111.             $ruleVersion->setAttainmentMeasure($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeRuleVersion(RuleVersion $ruleVersion): self
  116.     {
  117.         if ($this->ruleVersions->removeElement($ruleVersion)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($ruleVersion->getAttainmentMeasure() === $this) {
  120.                 $ruleVersion->setAttainmentMeasure(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125.     public function displayName()
  126.     {
  127.         return $this->getName();
  128.     }
  129.     /**
  130.      * @return Collection<int, RuleResult>
  131.      */
  132.     public function getRuleResults(): Collection
  133.     {
  134.         return $this->ruleResults;
  135.     }
  136.     public function addRuleResult(RuleResult $ruleResult): static
  137.     {
  138.         if (!$this->ruleResults->contains($ruleResult)) {
  139.             $this->ruleResults->add($ruleResult);
  140.             $ruleResult->setAttainmentMeasure($this);
  141.         }
  142.         return $this;
  143.     }
  144.     public function removeRuleResult(RuleResult $ruleResult): static
  145.     {
  146.         if ($this->ruleResults->removeElement($ruleResult)) {
  147.             // set the owning side to null (unless already changed)
  148.             if ($ruleResult->getAttainmentMeasure() === $this) {
  149.                 $ruleResult->setAttainmentMeasure(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154. }