1 | <?php |
||
2 | /** |
||
3 | * @package Localization |
||
4 | * @subpackage Countries |
||
5 | */ |
||
6 | |||
7 | declare(strict_types=1); |
||
8 | |||
9 | namespace AppLocalize\Localization\Countries; |
||
10 | |||
11 | use AppLocalize\Localization; |
||
12 | |||
13 | /** |
||
14 | * Individual country representation for handling country-related |
||
15 | * data like currencies and locales. |
||
16 | * |
||
17 | * @package Localization |
||
18 | * @subpackage Countries |
||
19 | * @author Sebastian Mordziol <[email protected]> |
||
20 | */ |
||
21 | abstract class BaseCountry implements CountryInterface |
||
22 | { |
||
23 | protected ?CountryCurrency $currency; |
||
24 | |||
25 | public function getCurrency() : CountryCurrency |
||
26 | { |
||
27 | if(!isset($this->currency)) { |
||
28 | $this->currency = new CountryCurrency( |
||
29 | Localization::createCurrencies()->getByID($this->getCurrencyISO()), |
||
30 | $this |
||
31 | ); |
||
32 | } |
||
33 | |||
34 | return $this->currency; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
35 | } |
||
36 | |||
37 | public function getID() : string |
||
38 | { |
||
39 | return $this->getCode(); |
||
40 | } |
||
41 | |||
42 | public function getCurrencyID() : string |
||
43 | { |
||
44 | return $this->getCurrencyISO(); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Returns the human-readable locale label. |
||
49 | * @return string |
||
50 | * @see getLabel() |
||
51 | */ |
||
52 | public function __toString() |
||
53 | { |
||
54 | return $this->getLabel(); |
||
55 | } |
||
56 | } |
||
57 |