Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
24 | 15 | public function __construct($onionHost) |
|
25 | { |
||
26 | 15 | $array = explode(".", $onionHost); |
|
27 | 15 | if (count($array) !== 2) { |
|
28 | 3 | throw new \InvalidArgumentException('Malformed onion address'); |
|
29 | } |
||
30 | |||
31 | 12 | list ($ident, $onion) = $array; |
|
32 | 12 | if ($onion !== 'onion') { |
|
33 | 3 | throw new \InvalidArgumentException('Malformed onion address'); |
|
34 | } |
||
35 | |||
36 | 9 | $decoded = Base32::decode($ident); |
|
37 | 9 | if (strlen($decoded) !== 10) { |
|
38 | 3 | throw new \InvalidArgumentException('Malformed onion address'); |
|
39 | } |
||
40 | |||
41 | 6 | $this->identifier = $decoded; |
|
42 | 6 | $this->host = $onionHost; |
|
43 | 6 | } |
|
44 | |||
61 |