src/Entity/Family.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Model\Entity;
  4. use App\Repository\FamilyRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassFamilyRepository::class)]
  9. class Family extends Entity
  10. {
  11.     #[ORM\Column(length255)]
  12.     private ?string $name null;
  13.     #[ORM\OneToMany(mappedBy'family'targetEntitySerie::class)]
  14.     private Collection $series;
  15.     #[ORM\OneToMany(mappedBy'family'targetEntityRange::class)]
  16.     private Collection $ranges;
  17.     #[ORM\ManyToMany(targetEntityProvider::class, mappedBy'families')]
  18.     private Collection $providers;
  19.     public function __construct(string $name null)
  20.     {
  21.         $this->name $name;
  22.         $this->series = new ArrayCollection();
  23.         $this->ranges = new ArrayCollection();
  24.         $this->providers = new ArrayCollection();
  25.     }
  26.     public function getName(): ?string
  27.     {
  28.         return $this->name;
  29.     }
  30.     public function setName(string $name): self
  31.     {
  32.         $this->name $name;
  33.         return $this;
  34.     }
  35.     /**
  36.      * @return Collection<int, Serie>
  37.      */
  38.     public function getSeries(): Collection
  39.     {
  40.         return $this->series;
  41.     }
  42.     public function addSeries(Serie $series): self
  43.     {
  44.         if (!$this->series->contains($series)) {
  45.             $this->series->add($series);
  46.             $series->setFamily($this);
  47.         }
  48.         return $this;
  49.     }
  50.     public function removeSeries(Serie $series): self
  51.     {
  52.         if ($this->series->removeElement($series)) {
  53.             // set the owning side to null (unless already changed)
  54.             if ($series->getFamily() === $this) {
  55.                 $series->setFamily(null);
  56.             }
  57.         }
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, Range>
  62.      */
  63.     public function getRanges(): Collection
  64.     {
  65.         return $this->ranges;
  66.     }
  67.     public function addRange(Range $range): self
  68.     {
  69.         if (!$this->ranges->contains($range)) {
  70.             $this->ranges->add($range);
  71.             $range->setFamily($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeRange(Range $range): self
  76.     {
  77.         if ($this->ranges->removeElement($range)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($range->getFamily() === $this) {
  80.                 $range->setFamily(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection<int, Provider>
  87.      */
  88.     public function getProviders(): Collection
  89.     {
  90.         return $this->providers;
  91.     }
  92.     public function addProvider(Provider $provider): self
  93.     {
  94.         if (!$this->providers->contains($provider)) {
  95.             $this->providers->add($provider);
  96.             $provider->addFamily($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeProvider(Provider $provider): self
  101.     {
  102.         if ($this->providers->removeElement($provider)) {
  103.             $provider->removeFamily($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function __toString(): string
  108.     {
  109.         return $this->name;
  110.     }
  111. }