| Total Complexity | 10 |
| Total Lines | 117 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class Country |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | private $name; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var string|null |
||
| 19 | */ |
||
| 20 | private $localName; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private $alpha2; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | private $alpha3; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var string |
||
| 34 | */ |
||
| 35 | private $numericCode; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Emoji of country flag |
||
| 39 | * |
||
| 40 | * @var string |
||
| 41 | */ |
||
| 42 | private $flag; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @var string |
||
| 46 | */ |
||
| 47 | private $officialName; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | private $commonName; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var TranslatorInterface |
||
| 56 | */ |
||
| 57 | private $translator; |
||
| 58 | |||
| 59 | public function __construct( |
||
| 60 | TranslatorInterface $translator, |
||
| 61 | string $name, |
||
| 62 | string $alpha2, |
||
| 63 | string $alpha3, |
||
| 64 | string $numericCode, |
||
| 65 | string $flag, |
||
| 66 | ?string $officialName = null, |
||
| 67 | ?string $commonName = null |
||
| 68 | ) { |
||
| 69 | $this->translator = $translator; |
||
| 70 | $this->name = $name; |
||
| 71 | $this->alpha2 = $alpha2; |
||
| 72 | $this->alpha3 = $alpha3; |
||
| 73 | $this->numericCode = $numericCode; |
||
| 74 | $this->flag = $flag; |
||
| 75 | $this->officialName = $officialName; |
||
| 76 | $this->commonName = $commonName; |
||
| 77 | } |
||
| 78 | |||
| 79 | public function getAlpha2(): string |
||
| 80 | { |
||
| 81 | return $this->alpha2; |
||
| 82 | } |
||
| 83 | |||
| 84 | public function getAlpha3(): string |
||
| 85 | { |
||
| 86 | return $this->alpha3; |
||
| 87 | } |
||
| 88 | |||
| 89 | public function getNumericCode(): string |
||
| 90 | { |
||
| 91 | return $this->numericCode; |
||
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @return string |
||
| 96 | */ |
||
| 97 | public function getFlag(): string |
||
| 100 | } |
||
| 101 | |||
| 102 | public function getName(): string |
||
| 103 | { |
||
| 104 | return $this->name; |
||
| 105 | } |
||
| 106 | |||
| 107 | public function getLocalName(): string |
||
| 108 | { |
||
| 109 | if ($this->localName === null) { |
||
| 110 | $this->localName = $this->translator->translate( |
||
| 111 | Countries::getISONumber(), |
||
| 112 | $this->name |
||
| 113 | ); |
||
| 114 | } |
||
| 115 | |||
| 116 | return $this->localName; |
||
| 117 | } |
||
| 118 | |||
| 119 | public function getOfficialName(): ?string |
||
| 120 | { |
||
| 121 | return $this->officialName; |
||
| 122 | } |
||
| 123 | |||
| 124 | public function getCommonName(): ?string |
||
| 127 | } |
||
| 128 | } |
||
| 129 |