Total Complexity | 9 |
Total Lines | 78 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class Geo extends Component |
||
14 | { |
||
15 | // Public Methods |
||
16 | // ========================================================================= |
||
17 | |||
18 | /** |
||
19 | * Get continents. |
||
20 | * |
||
21 | * @return array |
||
22 | */ |
||
23 | public function getContinents(): array |
||
24 | { |
||
25 | return $this->_getData('continents'); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Get subcontinents. |
||
30 | * |
||
31 | * @return array |
||
32 | */ |
||
33 | public function getSubContinents(): array |
||
34 | { |
||
35 | return $this->_getData('subContinents'); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get Continent Code |
||
40 | * |
||
41 | * @param string $label |
||
42 | * |
||
43 | * @return mixed |
||
44 | */ |
||
45 | public function getContinentCode($label) |
||
46 | { |
||
47 | foreach ($this->_getData('continents') as $continent) { |
||
48 | if ($continent['label'] === $label) { |
||
49 | return $continent['code']; |
||
50 | } |
||
51 | } |
||
52 | |||
53 | return null; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Get Sub-Continent Code |
||
58 | * |
||
59 | * @param string $label |
||
60 | * |
||
61 | * @return mixed |
||
62 | */ |
||
63 | public function getSubContinentCode($label) |
||
64 | { |
||
65 | foreach ($this->_getData('subContinents') as $subContinent) { |
||
66 | if ($subContinent['label'] === $label) { |
||
67 | return $subContinent['code']; |
||
68 | } |
||
69 | } |
||
70 | |||
71 | return null; |
||
72 | } |
||
73 | |||
74 | // Private Methods |
||
75 | // ========================================================================= |
||
76 | |||
77 | /** |
||
78 | * Get Data |
||
79 | * |
||
80 | * @param $name |
||
81 | * |
||
82 | * @return array |
||
83 | * @internal param string $label |
||
84 | * |
||
85 | */ |
||
86 | private function _getData($name): array |
||
91 | } |
||
92 | } |
||
93 |