src/Entity/Country.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CountryRepository;
  4. use Doctrine\DBAL\Types\Types;;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[ORM\Entity(repositoryClassCountryRepository::class)]
  9. #[UniqueEntity(['name'])]
  10. #[UniqueEntity(['externalId'])]
  11. class Country
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length64uniquetrue)]
  18.     #[Assert\NotBlank]
  19.     #[Assert\Length(min3max64)]
  20.     #[Assert\Regex(
  21.         pattern'/^[\p{L}\p{M}\s\'-]+$/u',
  22.     )]
  23.     private ?string $name null;
  24.     #[ORM\ManyToOne(targetEntityContinent::class)]
  25.     private ?Continent $continent null;
  26.     #[ORM\Column(type'boolean')]
  27.     private bool $active false;
  28.     #[ORM\Column(length3nullabletrue)]
  29.     private ?string $currency null;
  30.     #[Assert\NotBlank]
  31.     #[Assert\Positive]
  32.     #[Assert\LessThanOrEqual(value999)]
  33.     #[ORM\Column(typeTypes::SMALLINTnullabletrue)]
  34.     private ?int $prefix null;
  35.     #[Assert\NotBlank]
  36.     #[ORM\Column(length2nullabletrue)]
  37.     private ?string $codeAlpha2 null;
  38.     #[ORM\Column(nullabletrue)]
  39.     private ?int $externalId null;
  40.     public function getId()
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getName(): string
  45.     {
  46.         return $this->name;
  47.     }
  48.     public function setName(?string $name): self
  49.     {
  50.         $this->name $name;
  51.         return $this;
  52.     }
  53.     public function getContinent(): ?Continent
  54.     {
  55.         return $this->continent;
  56.     }
  57.     public function setContinent(Continent $continent): self
  58.     {
  59.         $this->continent $continent;
  60.         return $this;
  61.     }
  62.     public function isActive(): bool
  63.     {
  64.         return $this->active;
  65.     }
  66.     public function setActive(bool $active): self
  67.     {
  68.         $this->active $active;
  69.         return $this;
  70.     }
  71.     public function __toString(): string
  72.     {
  73.         return $this->name;
  74.     }
  75.     public function getCurrency(): string
  76.     {
  77.         return $this->currency;
  78.     }
  79.     public function setCurrency(?string $currency): self
  80.     {
  81.         $this->currency $currency;
  82.         return $this;
  83.     }
  84.     public function getPrefix(): ?int
  85.     {
  86.         return $this->prefix;
  87.     }
  88.     public function setPrefix(?int $prefix): self
  89.     {
  90.         $this->prefix $prefix;
  91.         return $this;
  92.     }
  93.     public function getCodeAlpha2(): ?string
  94.     {
  95.         return $this->codeAlpha2;
  96.     }
  97.     public function setCodeAlpha2(?string $codeAlpha2): static
  98.     {
  99.         $this->codeAlpha2 $codeAlpha2;
  100.         return $this;
  101.     }
  102.     public function getExternalId(): ?int
  103.     {
  104.         return $this->externalId;
  105.     }
  106.     public function setExternalId(?int $externalId): static
  107.     {
  108.         $this->externalId $externalId;
  109.         return $this;
  110.     }
  111. }