<?phpdeclare(strict_types=1);namespace App\Entity;use App\Repository\RegionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping\Column;use Doctrine\ORM\Mapping\Entity;use Doctrine\ORM\Mapping\GeneratedValue;use Doctrine\ORM\Mapping\Id;use Doctrine\ORM\Mapping\ManyToOne;use Doctrine\ORM\Mapping\OneToMany;#[Entity(RegionRepository::class)]class Region{ #[Id] #[GeneratedValue] #[Column(type: 'integer', options: ['unsigned' => true])] private ?int $id = null; #[ManyToOne(targetEntity: Region::class, inversedBy: 'children')] private ?Region $parent = null; #[OneToMany(mappedBy: 'parent', targetEntity: Region::class)] private Collection $children; #[OneToMany(mappedBy: 'region', targetEntity: Country::class)] private Collection $countries; #[Column(type: 'string')] private string $name; public function __construct() { $this->children = new ArrayCollection(); $this->countries = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getParent(): ?Region { return $this->parent; } public function setParent(?Region $parent): void { $this->parent = $parent; } public function getChildren(): Collection { return $this->children; } public function setChildren(Collection $children): void { $this->children = $children; } public function getCountries(): Collection { return $this->countries; } public function setCountries(Collection $countries): void { $this->countries = $countries; } public function getName(): string { return $this->name; } public function setName(string $name): void { $this->name = $name; } public function addChild(Region $child): self { if (!$this->children->contains($child)) { $this->children[] = $child; $child->setParent($this); } return $this; } public function removeChild(Region $child): self { if ($this->children->removeElement($child)) { if ($child->getParent() === $this) { $child->setParent(null); } } return $this; } public function addCountry(Country $country): self { if (!$this->countries->contains($country)) { $this->countries[] = $country; $country->setRegion($this); } return $this; } public function removeCountry(Country $country): self { if ($this->countries->removeElement($country)) { if ($country->getRegion() === $this) { $country->setRegion(null); } } return $this; }}