sokil /
php-isocodes
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Sokil\IsoCodes\Database\Countries; |
||
| 4 | |||
| 5 | use Sokil\IsoCodes\Database\Countries; |
||
| 6 | |||
| 7 | class Country |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | private $name; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | private $localName; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | private $alpha2; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | private $alpha3; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | private $numericCode; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | private $officialName; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Country constructor. |
||
| 41 | * @param string $name |
||
| 42 | * @param string $alpha2 |
||
| 43 | * @param string $alpha3 |
||
| 44 | * @param int $numericCode |
||
| 45 | * @param string|null $officialName |
||
| 46 | */ |
||
| 47 | public function __construct( |
||
| 48 | $name, |
||
| 49 | $alpha2, |
||
| 50 | $alpha3, |
||
| 51 | $numericCode, |
||
| 52 | $officialName = null |
||
| 53 | ) { |
||
| 54 | $this->name = $name; |
||
| 55 | $this->alpha2 = $alpha2; |
||
| 56 | $this->alpha3 = $alpha3; |
||
| 57 | $this->numericCode = $numericCode; |
||
| 58 | $this->officialName = $officialName; |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @return string |
||
| 63 | */ |
||
| 64 | public function getAlpha2() |
||
| 65 | { |
||
| 66 | return $this->alpha2; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | public function getAlpha3() |
||
| 73 | { |
||
| 74 | return $this->alpha3; |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @return int |
||
| 79 | */ |
||
| 80 | public function getNumericCode() |
||
| 81 | { |
||
| 82 | return $this->numericCode; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @return string |
||
| 87 | */ |
||
| 88 | public function getName() |
||
| 89 | { |
||
| 90 | return $this->name; |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @return string |
||
| 95 | */ |
||
| 96 | public function getLocalName() |
||
| 97 | { |
||
| 98 | if ($this->localName === null) { |
||
| 99 | $this->localName = dgettext( |
||
| 100 | Countries::getISONumber(), |
||
| 101 | $this->name |
||
| 102 | ); |
||
| 103 | } |
||
| 104 | |||
| 105 | return $this->localName; |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @return string|null |
||
| 110 | */ |
||
| 111 | public function getOfficialName() |
||
| 112 | { |
||
| 113 | return $this->officialName; |
||
| 114 | } |
||
| 115 | } |
||
| 116 |