<?php
namespace App\Entity;
use App\Repository\DiseaseCategoryRepository;
use Doctrine\Common\Collections\{ ArrayCollection, Collection };
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: DiseaseCategoryRepository::class), ORM\Table(name: 'disease_categories')]
class DiseaseCategory implements \Stringable
{
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\OneToMany(targetEntity: Symptom::class, mappedBy: 'diseaseCategory', orphanRemoval: true)]
private $symptoms;
public function __construct()
{
$this->symptoms = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection|Symptom[]
*/
public function getSymptoms(): Collection
{
return $this->symptoms;
}
public function addSymptom(Symptom $symptom): self
{
if (!$this->symptoms->contains($symptom)) {
$this->symptoms[] = $symptom;
$symptom->setDiseaseCategory($this);
}
return $this;
}
public function removeSymptom(Symptom $symptom): self
{
if ($this->symptoms->contains($symptom)) {
$this->symptoms->removeElement($symptom);
if ($symptom->getDiseaseCategory() === $this) {
$symptom->setDiseaseCategory(null);
}
}
return $this;
}
public function __toString(): string
{
return $this->getName();
}
}