1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\currency; |
4
|
|
|
|
5
|
|
|
use EE_Error; |
6
|
|
|
use EE_Organization_Config; |
7
|
|
|
use EventEspresso\core\domain\values\currency\Currency; |
8
|
|
|
use EventEspresso\core\entities\Label; |
9
|
|
|
use InvalidArgumentException; |
10
|
|
|
|
11
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class CurrencyFactory |
17
|
|
|
* Factory class for creating Currency objects |
18
|
|
|
* |
19
|
|
|
* @package EventEspresso\core\services\currency |
20
|
|
|
* @author Brent Christensen |
21
|
|
|
* @since $VID:$ |
22
|
|
|
*/ |
23
|
|
|
class CurrencyFactory |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var CountryCurrencyDao $country_currencies |
28
|
|
|
*/ |
29
|
|
|
private $country_currencies; |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* CurrencyFactory constructor. |
34
|
|
|
* |
35
|
|
|
* @param CountryCurrencyDao $country_currencies |
36
|
|
|
* @param EE_Organization_Config $organization_config |
|
|
|
|
37
|
|
|
*/ |
38
|
|
|
public function __construct(CountryCurrencyDao $country_currencies) |
39
|
|
|
{ |
40
|
|
|
$this->country_currencies = $country_currencies; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param array $country_currency |
46
|
|
|
* @return Currency |
47
|
|
|
*/ |
48
|
|
|
private function createCurrencyFromCountryCurrency(array $country_currency) |
49
|
|
|
{ |
50
|
|
|
return new Currency( |
51
|
|
|
$country_currency['CurrencyCode'], |
52
|
|
|
new Label( |
53
|
|
|
$country_currency['CurrencyNameSingle'], |
54
|
|
|
$country_currency['CurrencyNamePlural'] |
55
|
|
|
), |
56
|
|
|
$country_currency['CurrencySign'], |
57
|
|
|
$country_currency['CurrencySignB4'], |
58
|
|
|
$country_currency['CurrencyDecimalPlaces'], |
59
|
|
|
$country_currency['CurrencyDecimalMark'], |
60
|
|
|
$country_currency['CurrencyThousands'], |
61
|
|
|
$country_currency['CurrencySubunits'], |
62
|
|
|
$country_currency['CurrencySignSeparator'] |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* returns a Currency object for the supplied country code |
69
|
|
|
* |
70
|
|
|
* @param string $CNT_ISO |
71
|
|
|
* @return Currency |
72
|
|
|
* @throws EE_Error |
73
|
|
|
* @throws InvalidArgumentException |
74
|
|
|
*/ |
75
|
|
|
public function createFromCountryCode($CNT_ISO) |
76
|
|
|
{ |
77
|
|
|
return $this->createCurrencyFromCountryCurrency( |
78
|
|
|
$this->country_currencies->getCountryCurrencyByIsoCode($CNT_ISO) |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* returns a Currency object for the supplied currency code |
85
|
|
|
* PLZ NOTE: variations may exist between how different countries display the same currency, |
86
|
|
|
* so it may be necessary to use CreateCurrency::fromCountryCode() to achieve the desired results |
87
|
|
|
* |
88
|
|
|
* @param string $code |
89
|
|
|
* @return Currency |
90
|
|
|
* @throws InvalidArgumentException |
91
|
|
|
* @throws EE_Error |
92
|
|
|
*/ |
93
|
|
|
public function createFromCode($code) |
94
|
|
|
{ |
95
|
|
|
return $this->createCurrencyFromCountryCurrency( |
96
|
|
|
$this->country_currencies->getCountryCurrencyByCurrencyCode($code) |
97
|
|
|
); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
// Location: CreateCurrency.php |
101
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.