src/Entity/DiseaseCategory.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DiseaseCategoryRepository;
  4. use Doctrine\Common\Collections\{ ArrayCollectionCollection };
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassDiseaseCategoryRepository::class), ORM\Table(name'disease_categories')]
  7. class DiseaseCategory implements \Stringable
  8. {
  9.     #[ORM\IdORM\GeneratedValueORM\Column(type'integer')]
  10.     private $id;
  11.     #[ORM\Column(type'string'length255)]
  12.     private $name;
  13.     #[ORM\OneToMany(targetEntitySymptom::class, mappedBy'diseaseCategory'orphanRemovaltrue)]
  14.     private $symptoms;
  15.     public function __construct()
  16.     {
  17.         $this->symptoms = new ArrayCollection();
  18.     }
  19.     public function getId(): ?int
  20.     {
  21.         return $this->id;
  22.     }
  23.     public function getName(): ?string
  24.     {
  25.         return $this->name;
  26.     }
  27.     public function setName(string $name): self
  28.     {
  29.         $this->name $name;
  30.         return $this;
  31.     }
  32.     /**
  33.      * @return Collection|Symptom[]
  34.      */
  35.     public function getSymptoms(): Collection
  36.     {
  37.         return $this->symptoms;
  38.     }
  39.     public function addSymptom(Symptom $symptom): self
  40.     {
  41.         if (!$this->symptoms->contains($symptom)) {
  42.             $this->symptoms[] = $symptom;
  43.             $symptom->setDiseaseCategory($this);
  44.         }
  45.         return $this;
  46.     }
  47.     public function removeSymptom(Symptom $symptom): self
  48.     {
  49.         if ($this->symptoms->contains($symptom)) {
  50.             $this->symptoms->removeElement($symptom);
  51.             if ($symptom->getDiseaseCategory() === $this) {
  52.                 $symptom->setDiseaseCategory(null);
  53.             }
  54.         }
  55.         return $this;
  56.     }
  57.     public function __toString(): string
  58.     {
  59.         return $this->getName();
  60.     }
  61. }