vendor/crea/tools-bundle/src/Entity/Geographic/Country.php line 23

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Crea\ToolsBundle\Entity\Geographic;
  4. use Crea\ToolsBundle\Repository\Geographic\CountryRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * @ORM\Entity(repositoryClass=CountryRepository::class)
  10. *
  11. * @ORM\Table(
  12. * name="geographic_country",
  13. * uniqueConstraints={
  14. *
  15. * @ORM\UniqueConstraint(name="geographic_country_iso_id", columns={"id"})
  16. * },
  17. * )
  18. */
  19. class Country implements \Stringable
  20. {
  21. /**
  22. * @ORM\Id
  23. *
  24. * @ORM\Column(type="integer")
  25. */
  26. private int $id;
  27. /**
  28. * @ORM\Column(type="string", nullable=false)
  29. */
  30. private string $label;
  31. /**
  32. * @ORM\Column(type="string", nullable=false)
  33. */
  34. private string $alpha2;
  35. /**
  36. * @ORM\Column(type="string", nullable=false)
  37. */
  38. private string $alpha3;
  39. /**
  40. * @ORM\Column(type="string", nullable=true)
  41. */
  42. private ?string $name = null;
  43. /**
  44. * @ORM\Column(type="string", nullable=false)
  45. */
  46. private string $isoName;
  47. /**
  48. * @ORM\Column(type="string", nullable=true)
  49. */
  50. private ?string $nationality = null;
  51. /**
  52. * @ORM\Column(type="integer", nullable=false, options={"default" : 0})
  53. */
  54. private int $displayPriority = 0;
  55. /**
  56. * @var Collection<int, City>
  57. *
  58. * @ORM\OneToMany(targetEntity=City::class, mappedBy="country")
  59. */
  60. private Collection $cities;
  61. public function __construct()
  62. {
  63. $this->cities = new ArrayCollection();
  64. }
  65. public function __toString(): string
  66. {
  67. return mb_convert_case($this->getIsoName(), MB_CASE_TITLE);
  68. }
  69. public function getId(): int
  70. {
  71. return $this->id;
  72. }
  73. public function setId(int $id): self
  74. {
  75. $this->id = $id;
  76. return $this;
  77. }
  78. public function getLabel(): string
  79. {
  80. return $this->label;
  81. }
  82. public function setLabel(string $label): self
  83. {
  84. $this->label = $label;
  85. return $this;
  86. }
  87. public function getAlpha2(): string
  88. {
  89. return $this->alpha2;
  90. }
  91. public function setAlpha2(string $alpha2): self
  92. {
  93. $this->alpha2 = $alpha2;
  94. return $this;
  95. }
  96. public function getAlpha3(): string
  97. {
  98. return $this->alpha3;
  99. }
  100. public function setAlpha3(string $alpha3): self
  101. {
  102. $this->alpha3 = $alpha3;
  103. return $this;
  104. }
  105. public function getName(): ?string
  106. {
  107. return $this->name;
  108. }
  109. public function setName(?string $name): self
  110. {
  111. $this->name = $name;
  112. return $this;
  113. }
  114. public function getIsoName(): string
  115. {
  116. return $this->isoName;
  117. }
  118. public function setIsoName(string $isoName): self
  119. {
  120. $this->isoName = $isoName;
  121. return $this;
  122. }
  123. public function getNationality(): ?string
  124. {
  125. return $this->nationality;
  126. }
  127. public function setNationality(?string $nationality): self
  128. {
  129. $this->nationality = $nationality;
  130. return $this;
  131. }
  132. public function getDisplayPriority(): int
  133. {
  134. return $this->displayPriority;
  135. }
  136. public function setDisplayPriority(int $displayPriority): self
  137. {
  138. $this->displayPriority = $displayPriority;
  139. return $this;
  140. }
  141. /**
  142. * @return Collection<int, City>
  143. */
  144. public function getCities()
  145. {
  146. return $this->cities;
  147. }
  148. /**
  149. * @param Collection<int, City> $cities
  150. */
  151. public function setCities(Collection $cities): self
  152. {
  153. $this->cities = $cities;
  154. return $this;
  155. }
  156. public function addCity(City $city): self
  157. {
  158. if (!$this->cities->contains($city)) {
  159. $this->cities[] = $city;
  160. $city->setCountry($this);
  161. }
  162. return $this;
  163. }
  164. public function removeCity(City $city): self
  165. {
  166. $this->cities->removeElement($city);
  167. return $this;
  168. }
  169. }