Total Complexity | 6 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | class Currency implements CurrencyInterface, \JsonSerializable |
||
14 | { |
||
15 | private const _CODE_LENGTH = 9; |
||
16 | |||
17 | /** @var string */ |
||
18 | private $code; |
||
19 | |||
20 | /** |
||
21 | * @param string $code |
||
22 | */ |
||
23 | 132 | public function __construct(string $code) |
|
29 | 131 | } |
|
30 | |||
31 | /** |
||
32 | * Checks whether this currency is the same as an other. |
||
33 | * |
||
34 | * @param Currency $currency |
||
35 | * |
||
36 | * @return bool |
||
37 | */ |
||
38 | 51 | public function equals(Currency $currency): bool |
|
39 | { |
||
40 | 51 | return $this->code === $currency->code; |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * @return string |
||
45 | */ |
||
46 | 22 | public function __toString() |
|
47 | { |
||
48 | 22 | return $this->getCode(); |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Returns the currency code. |
||
53 | */ |
||
54 | 23 | public function getCode(): string |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | 2 | public function jsonSerialize(): string |
|
65 | } |
||
66 | } |