Total Complexity | 5 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Coverage | 63.64% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
17 | final class Bitcoin extends Money implements MakeEmptyInterface |
||
18 | { |
||
19 | /** @param string $value */ |
||
20 | 7 | public static function fromNative($value): self |
|
21 | { |
||
22 | 7 | Assertion::string($value, 'Must be a string.'); |
|
23 | |||
24 | 7 | if (!preg_match('/^(?<amount>-?\d+)\s?(?<currency>M?SAT|BTC|XBT)$/i', $value, $matches)) { |
|
25 | 2 | throw new InvalidArgumentException('Invalid amount.'); |
|
26 | } |
||
27 | |||
28 | 7 | return new self(self::asBaseMoney($matches['amount'], strtoupper($matches['currency']))); |
|
29 | } |
||
30 | |||
31 | 1 | public static function zero($currency = null): self |
|
32 | { |
||
33 | 1 | return self::fromNative('0'.($currency ?? SatoshiCurrencies::MSAT)); |
|
34 | } |
||
35 | |||
36 | public static function makeEmpty(): self |
||
39 | } |
||
40 | |||
41 | public function isEmpty(): bool |
||
44 | } |
||
45 | } |
||
46 |