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