|
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_Country_AT; |
|
12
|
|
|
use AppLocalize\Localization_Country_CA; |
|
13
|
|
|
use AppLocalize\Localization_Country_DE; |
|
14
|
|
|
use AppLocalize\Localization_Country_ES; |
|
15
|
|
|
use AppLocalize\Localization_Country_FR; |
|
16
|
|
|
use AppLocalize\Localization_Country_IT; |
|
17
|
|
|
use AppLocalize\Localization_Country_MX; |
|
18
|
|
|
use AppLocalize\Localization_Country_PL; |
|
19
|
|
|
use AppLocalize\Localization_Country_RO; |
|
20
|
|
|
use AppLocalize\Localization_Country_UK; |
|
21
|
|
|
use AppLocalize\Localization_Country_US; |
|
22
|
|
|
use AppLocalize\Localization_Country_ZZ; |
|
23
|
|
|
use AppUtils\Collections\BaseStringPrimaryCollection; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Country collection that gives access to all available |
|
27
|
|
|
* countries and their data. |
|
28
|
|
|
* |
|
29
|
|
|
* @package Localization |
|
30
|
|
|
* @subpackage Countries |
|
31
|
|
|
* |
|
32
|
|
|
* @method BaseCountry getByID(string $id) |
|
33
|
|
|
* @method BaseCountry getDefault() |
|
34
|
|
|
* @method BaseCountry[] getAll() |
|
35
|
|
|
*/ |
|
36
|
|
|
class CountryCollection extends BaseStringPrimaryCollection |
|
37
|
|
|
{ |
|
38
|
|
|
private static ?CountryCollection $instance = null; |
|
39
|
|
|
|
|
40
|
|
|
private function __construct() |
|
41
|
|
|
{ |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public static function getInstance(): CountryCollection |
|
45
|
|
|
{ |
|
46
|
|
|
if (self::$instance === null) { |
|
47
|
|
|
self::$instance = new self(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return self::$instance; |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function getDefaultID(): string |
|
54
|
|
|
{ |
|
55
|
|
|
return Localization_Country_US::ISO_CODE; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
protected function registerItems(): void |
|
59
|
|
|
{ |
|
60
|
|
|
$this->registerItem(new Localization_Country_AT()); |
|
61
|
|
|
$this->registerItem(new Localization_Country_CA()); |
|
62
|
|
|
$this->registerItem(new Localization_Country_DE()); |
|
63
|
|
|
$this->registerItem(new Localization_Country_ES()); |
|
64
|
|
|
$this->registerItem(new Localization_Country_FR()); |
|
65
|
|
|
$this->registerItem(new Localization_Country_IT()); |
|
66
|
|
|
$this->registerItem(new Localization_Country_MX()); |
|
67
|
|
|
$this->registerItem(new Localization_Country_PL()); |
|
68
|
|
|
$this->registerItem(new Localization_Country_RO()); |
|
69
|
|
|
$this->registerItem(new Localization_Country_UK()); |
|
70
|
|
|
$this->registerItem(new Localization_Country_US()); |
|
71
|
|
|
$this->registerItem(new Localization_Country_ZZ()); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
private ?CannedCountries $canned = null; |
|
75
|
|
|
|
|
76
|
|
|
public function choose() : CannedCountries |
|
77
|
|
|
{ |
|
78
|
|
|
if(!isset($this->canned)) { |
|
79
|
|
|
$this->canned = new CannedCountries(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
return $this->canned; |
|
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|