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