PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / moneyphp / money / src / Currencies / CurrencyList.php
ameliabooking / vendor / moneyphp / money / src / Currencies Last commit date
AggregateCurrencies.php 2 years ago BitcoinCurrencies.php 2 years ago CachedCurrencies.php 2 years ago CurrencyList.php 2 years ago ISOCurrencies.php 2 years ago
CurrencyList.php
74 lines
1 <?php
2
3 namespace Money\Currencies;
4
5 use Money\Currencies;
6 use Money\Currency;
7 use Money\Exception\UnknownCurrencyException;
8
9 /**
10 * A list of custom currencies.
11 *
12 * @author George Mponos <gmponos@gmail.com>
13 */
14 final class CurrencyList implements Currencies
15 {
16 /**
17 * Map of currencies indexed by code.
18 *
19 * @var array
20 */
21 private $currencies;
22
23 public function __construct(array $currencies)
24 {
25 foreach ($currencies as $currencyCode => $subunit) {
26 if (empty($currencyCode) || !is_string($currencyCode)) {
27 throw new \InvalidArgumentException(sprintf('Currency code must be a string and not empty. "%s" given', $currencyCode));
28 }
29
30 if (!is_int($subunit) || $subunit < 0) {
31 throw new \InvalidArgumentException(sprintf('Currency %s does not have a valid minor unit. Must be a positive integer.', $currencyCode));
32 }
33 }
34
35 $this->currencies = $currencies;
36 }
37
38 /**
39 * {@inheritdoc}
40 */
41 public function contains(Currency $currency)
42 {
43 return isset($this->currencies[$currency->getCode()]);
44 }
45
46 /**
47 * {@inheritdoc}
48 */
49 public function subunitFor(Currency $currency)
50 {
51 if (!$this->contains($currency)) {
52 throw new UnknownCurrencyException('Cannot find currency '.$currency->getCode());
53 }
54
55 return $this->currencies[$currency->getCode()];
56 }
57
58 /**
59 * {@inheritdoc}
60 */
61 #[\ReturnTypeWillChange]
62 public function getIterator()
63 {
64 return new \ArrayIterator(
65 array_map(
66 function ($code) {
67 return new Currency($code);
68 },
69 array_keys($this->currencies)
70 )
71 );
72 }
73 }
74