<?php
declare(strict_types=1);
namespace Crea\ToolsBundle\Entity\Geographic;
use Crea\ToolsBundle\Repository\Geographic\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="geographic_country",
* uniqueConstraints={
*
* @ORM\UniqueConstraint(name="geographic_country_iso_id", columns={"id"})
* },
* )
*/
class Country implements \Stringable
{
/**
* @ORM\Id
*
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @ORM\Column(type="string", nullable=false)
*/
private string $label;
/**
* @ORM\Column(type="string", nullable=false)
*/
private string $alpha2;
/**
* @ORM\Column(type="string", nullable=false)
*/
private string $alpha3;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $name = null;
/**
* @ORM\Column(type="string", nullable=false)
*/
private string $isoName;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $nationality = null;
/**
* @ORM\Column(type="integer", nullable=false, options={"default" : 0})
*/
private int $displayPriority = 0;
/**
* @var Collection<int, City>
*
* @ORM\OneToMany(targetEntity=City::class, mappedBy="country")
*/
private Collection $cities;
public function __construct()
{
$this->cities = new ArrayCollection();
}
public function __toString(): string
{
return mb_convert_case($this->getIsoName(), MB_CASE_TITLE);
}
public function getId(): int
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getLabel(): string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getAlpha2(): string
{
return $this->alpha2;
}
public function setAlpha2(string $alpha2): self
{
$this->alpha2 = $alpha2;
return $this;
}
public function getAlpha3(): string
{
return $this->alpha3;
}
public function setAlpha3(string $alpha3): self
{
$this->alpha3 = $alpha3;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getIsoName(): string
{
return $this->isoName;
}
public function setIsoName(string $isoName): self
{
$this->isoName = $isoName;
return $this;
}
public function getNationality(): ?string
{
return $this->nationality;
}
public function setNationality(?string $nationality): self
{
$this->nationality = $nationality;
return $this;
}
public function getDisplayPriority(): int
{
return $this->displayPriority;
}
public function setDisplayPriority(int $displayPriority): self
{
$this->displayPriority = $displayPriority;
return $this;
}
/**
* @return Collection<int, City>
*/
public function getCities()
{
return $this->cities;
}
/**
* @param Collection<int, City> $cities
*/
public function setCities(Collection $cities): self
{
$this->cities = $cities;
return $this;
}
public function addCity(City $city): self
{
if (!$this->cities->contains($city)) {
$this->cities[] = $city;
$city->setCountry($this);
}
return $this;
}
public function removeCity(City $city): self
{
$this->cities->removeElement($city);
return $this;
}
}