@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | namespace Thunder\Currenz; |
| 4 | 4 | |
| 5 | 5 | final class Currency extends AbstractCurrency |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | namespace Thunder\Currenz\Utility; |
| 4 | 4 | |
| 5 | 5 | final class Utility |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | $data = []; |
| 17 | 17 | /** @var \DOMElement $node */ |
| 18 | - foreach($xml->childNodes[0]->childNodes[1]->childNodes as $node) { |
|
| 19 | - if(XML_ELEMENT_NODE !== $node->nodeType) { |
|
| 18 | + foreach ($xml->childNodes[0]->childNodes[1]->childNodes as $node) { |
|
| 19 | + if (XML_ELEMENT_NODE !== $node->nodeType) { |
|
| 20 | 20 | continue; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | $code = $value($node, 'Ccy'); |
| 24 | 24 | $country = $value($node, 'CtryNm'); |
| 25 | - if(false === array_key_exists($code, $data)) { |
|
| 25 | + if (false === array_key_exists($code, $data)) { |
|
| 26 | 26 | $data[$code] = [ |
| 27 | 27 | 'code' => $code, |
| 28 | 28 | 'countries' => [$country], |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | 'units' => $value($node, 'CcyMnrUnts'), |
| 32 | 32 | ]; |
| 33 | 33 | } |
| 34 | - if(false === in_array($country, $data[$code]['countries'], true)) { |
|
| 34 | + if (false === in_array($country, $data[$code]['countries'], true)) { |
|
| 35 | 35 | $data[$code]['countries'][] = $country; |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | namespace Thunder\Currenz; |
| 4 | 4 | |
| 5 | 5 | use Prophecy\Exception\InvalidArgumentException; |
@@ -14,24 +14,24 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public function __construct(string $name, string $code, ?int $digits, array $countries, string $number) |
| 16 | 16 | { |
| 17 | - if(empty($name)) { |
|
| 17 | + if (empty($name)) { |
|
| 18 | 18 | throw new \InvalidArgumentException('Currency name must not be empty!'); |
| 19 | 19 | } |
| 20 | - if(!preg_match('~^[A-Z]{3}$~', $code)) { |
|
| 20 | + if (!preg_match('~^[A-Z]{3}$~', $code)) { |
|
| 21 | 21 | throw new \InvalidArgumentException(sprintf('ISO4217 currency code must be an uppercase three-letter string, `%s` given!', $code)); |
| 22 | 22 | } |
| 23 | - if($digits !== null && $digits < 0) { |
|
| 23 | + if ($digits !== null && $digits < 0) { |
|
| 24 | 24 | throw new \InvalidArgumentException(sprintf('Currency digits must be a non-negative integer or null, `%s` given!', $digits)); |
| 25 | 25 | } |
| 26 | - foreach($countries as $country) { |
|
| 27 | - if(false === is_string($country)) { |
|
| 26 | + foreach ($countries as $country) { |
|
| 27 | + if (false === is_string($country)) { |
|
| 28 | 28 | throw new InvalidArgumentException('Currency country name must be a string!'); |
| 29 | 29 | } |
| 30 | - if(empty($country)) { |
|
| 30 | + if (empty($country)) { |
|
| 31 | 31 | throw new \InvalidArgumentException('Currency country name must not be empty!'); |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | - if(!preg_match('~^[0-9]{3}$~', $number)) { |
|
| 34 | + if (!preg_match('~^[0-9]{3}$~', $number)) { |
|
| 35 | 35 | throw new \InvalidArgumentException(sprintf('ISO4217 currency number must be a three-digit string, `%s` given!', $number)); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public function getUnits(): int |
| 61 | 61 | { |
| 62 | - if(null === $this->digits) { |
|
| 62 | + if (null === $this->digits) { |
|
| 63 | 63 | return 0; |
| 64 | 64 | } |
| 65 | 65 | |