|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package Localization |
|
4
|
|
|
* @subpackage Currencies |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
declare(strict_types=1); |
|
8
|
|
|
|
|
9
|
|
|
namespace AppLocalize\Localization\Currencies; |
|
10
|
|
|
|
|
11
|
|
|
use AppLocalize\Localization_Currency_CAD; |
|
12
|
|
|
use AppLocalize\Localization_Currency_CHF; |
|
13
|
|
|
use AppLocalize\Localization_Currency_EUR; |
|
14
|
|
|
use AppLocalize\Localization_Currency_GBP; |
|
15
|
|
|
use AppLocalize\Localization_Currency_MXN; |
|
16
|
|
|
use AppLocalize\Localization_Currency_PLN; |
|
17
|
|
|
use AppLocalize\Localization_Currency_RON; |
|
18
|
|
|
use AppLocalize\Localization_Currency_USD; |
|
19
|
|
|
use AppUtils\Collections\BaseStringPrimaryCollection; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @package Localization |
|
23
|
|
|
* @subpackage Currencies |
|
24
|
|
|
* |
|
25
|
|
|
* @method CurrencyInterface getByID(string $id) |
|
26
|
|
|
* @method CurrencyInterface getDefault() |
|
27
|
|
|
* @method CurrencyInterface[] getAll() |
|
28
|
|
|
*/ |
|
29
|
|
|
class CurrencyCollection extends BaseStringPrimaryCollection |
|
30
|
|
|
{ |
|
31
|
|
|
private static ?CurrencyCollection $instance = null; |
|
32
|
|
|
|
|
33
|
|
|
private function __construct() |
|
34
|
|
|
{ |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public static function getInstance(): CurrencyCollection |
|
38
|
|
|
{ |
|
39
|
|
|
if (self::$instance === null) { |
|
40
|
|
|
self::$instance = new self(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return self::$instance; |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getDefaultID(): string |
|
47
|
|
|
{ |
|
48
|
|
|
return Localization_Currency_USD::ISO_CODE; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
protected function registerItems(): void |
|
52
|
|
|
{ |
|
53
|
|
|
$this->registerItem(new Localization_Currency_CAD()); |
|
54
|
|
|
$this->registerItem(new Localization_Currency_CHF()); |
|
55
|
|
|
$this->registerItem(new Localization_Currency_EUR()); |
|
56
|
|
|
$this->registerItem(new Localization_Currency_GBP()); |
|
57
|
|
|
$this->registerItem(new Localization_Currency_MXN()); |
|
58
|
|
|
$this->registerItem(new Localization_Currency_PLN()); |
|
59
|
|
|
$this->registerItem(new Localization_Currency_RON()); |
|
60
|
|
|
$this->registerItem(new Localization_Currency_USD()); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
private ?CannedCurrencies $canned = null; |
|
64
|
|
|
|
|
65
|
|
|
public function choose() : CannedCurrencies |
|
66
|
|
|
{ |
|
67
|
|
|
if(!isset($this->canned)) { |
|
68
|
|
|
$this->canned = new CannedCurrencies(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return $this->canned; |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|