| Conditions | 8 |
| Paths | 6 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 8 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 40 | public function __construct(array $registry) |
|
| 19 | { |
||
| 20 | 40 | foreach ($registry as $scriptType => $prefixes) { |
|
| 21 | 39 | if (!is_string($scriptType)) { |
|
| 22 | 1 | throw new \InvalidArgumentException("Expecting script type as key"); |
|
| 23 | } |
||
| 24 | 38 | if (count($prefixes) !== 2) { |
|
| 25 | 1 | throw new \InvalidArgumentException("Expecting two BIP32 prefixes"); |
|
| 26 | } |
||
| 27 | // private, public |
||
| 28 | 37 | if (strlen($prefixes[0]) !== 8 || !ctype_xdigit($prefixes[0])) { |
|
| 29 | 1 | throw new \InvalidArgumentException("Invalid private prefix"); |
|
| 30 | } |
||
| 31 | 36 | if (strlen($prefixes[1]) !== 8 || !ctype_xdigit($prefixes[1])) { |
|
| 32 | 36 | throw new \InvalidArgumentException("Invalid public prefix"); |
|
| 33 | } |
||
| 34 | } |
||
| 35 | 36 | $this->registry = $registry; |
|
| 36 | 36 | } |
|
| 37 | |||
| 50 |