src/Entity/Rank.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RankRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="rank")
  9.  * @ORM\Entity(repositoryClass=RankRepository::class)
  10.  */
  11. class Rank
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $name;
  23.     /**
  24.      * @ORM\OneToMany(targetEntity=Respondent::class, mappedBy="rank")
  25.      */
  26.     private $respondents;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity=TrainingRank::class, mappedBy="rank")
  29.      */
  30.     private $trainingRanks;
  31.     public function __construct()
  32.     {
  33.         $this->respondents = new ArrayCollection();
  34.         $this->trainingRanks = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getName(): ?string
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function setName(string $name): self
  45.     {
  46.         $this->name $name;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Respondent>
  51.      */
  52.     public function getRespondents(): Collection
  53.     {
  54.         return $this->respondents;
  55.     }
  56.     public function addRespondent(Respondent $respondent): self
  57.     {
  58.         if (!$this->respondents->contains($respondent)) {
  59.             $this->respondents[] = $respondent;
  60.             $respondent->setRank($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeRespondent(Respondent $respondent): self
  65.     {
  66.         if ($this->respondents->removeElement($respondent)) {
  67.             // set the owning side to null (unless already changed)
  68.             if ($respondent->getRank() === $this) {
  69.                 $respondent->setRank(null);
  70.             }
  71.         }
  72.         return $this;
  73.     }
  74.     public function __toString(): string
  75.     {
  76.         return $this->name;
  77.     }
  78.     /**
  79.      * @return Collection<int, TrainingRank>
  80.      */
  81.     public function getTrainingRanks(): Collection
  82.     {
  83.         return $this->trainingRanks;
  84.     }
  85.     public function addTrainingRank(TrainingRank $trainingRank): self
  86.     {
  87.         if (!$this->trainingRanks->contains($trainingRank)) {
  88.             $this->trainingRanks[] = $trainingRank;
  89.             $trainingRank->setRank($this);
  90.         }
  91.         return $this;
  92.     }
  93.     public function removeTrainingRank(TrainingRank $trainingRank): self
  94.     {
  95.         if ($this->trainingRanks->removeElement($trainingRank)) {
  96.             // set the owning side to null (unless already changed)
  97.             if ($trainingRank->getRank() === $this) {
  98.                 $trainingRank->setRank(null);
  99.             }
  100.         }
  101.         return $this;
  102.     }
  103. }