| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 3.0261 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 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 | } |
||
| 39 |