Total Complexity | 4 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Coverage | 88.89% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
16 | final class Bitcoin extends Money |
||
17 | { |
||
18 | /** @param null|string $value */ |
||
19 | 7 | public static function fromNative($value): self |
|
20 | { |
||
21 | 7 | Assertion::nullOrString($value, 'Must be a string.'); |
|
22 | 7 | if ($value === null) { |
|
23 | return new self; |
||
24 | } |
||
25 | |||
26 | 7 | if (!preg_match('/^(?<amount>-?\d+)\s?(?<currency>M?SAT|BTC|XBT)$/i', $value, $matches)) { |
|
27 | 2 | throw new InvalidArgumentException('Invalid amount.'); |
|
28 | } |
||
29 | |||
30 | 7 | return new self(self::asBaseMoney($matches['amount'], strtoupper($matches['currency']))); |
|
31 | } |
||
32 | |||
33 | 1 | public static function zero($currency = null): self |
|
36 | } |
||
37 | } |
||
38 |