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