src/Entity/Country.php line 15
<?phpnamespace App\Entity;use App\Repository\CountryRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/*** @ORM\Entity(repositoryClass=CountryRepository::class)* @ORM\Table(name="country")* @ORM\HasLifecycleCallbacks()*/class Country{/*** @ORM\Id* @ORM\GeneratedValue* @ORM\Column(type="integer")*/private ?int $id = null;/*** @ORM\Column(type="string", length=100)*/private string $name;/*** ISO 3166-1 alpha-2, e.g. "AM", "FR"* @ORM\Column(type="string", length=2, unique=true)*/private string $code;/*** @ORM\Column(type="string", length=120, unique=true)*/private string $slug;/*** @ORM\Column(type="boolean", options={"default": true})*/private bool $isActive = true;/*** @ORM\Column(type="datetime_immutable")*/private \DateTimeImmutable $createdAt;/*** @ORM\OneToMany(targetEntity=City::class, mappedBy="country", cascade={"persist"}, orphanRemoval=true)*/private Collection $cities;public function __construct(){$this->cities = new ArrayCollection();$this->createdAt = new \DateTimeImmutable();}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;}public function getCode(): string{return $this->code;}public function setCode(string $code): self{$this->code = strtoupper($code);return $this;}public function getSlug(): string{return $this->slug;}public function setSlug(string $slug): self{$this->slug = $slug;return $this;}public function isActive(): bool{return $this->isActive;}public function setIsActive(bool $isActive): self{$this->isActive = $isActive;return $this;}public function getCreatedAt(): \DateTimeImmutable{return $this->createdAt;}public function getCities(): Collection{return $this->cities;}public function addCity(City $city): self{if (!$this->cities->contains($city)) {$this->cities->add($city);$city->setCountry($this);}return $this;}public function removeCity(City $city): self{if ($this->cities->removeElement($city)) {if ($city->getCountry() === $this) {$city->setCountry(null);}}return $this;}public function __toString(): string{return ($this->title ?? '');}}