| Conditions | 2 |
| Paths | 2 |
| Total Lines | 9 |
| Code Lines | 4 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 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 | } |
||
| 46 |