Conditions | 3 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
23 | public function __construct(string $ip, Validator $validator = null) |
||
24 | { |
||
25 | if ($validator == null) { |
||
26 | // use the default validator |
||
27 | $validator = new IPAddressValidator(); |
||
28 | } |
||
29 | |||
30 | $result = $validator->validate($ip); |
||
31 | if (!$result->isValid()) { |
||
32 | /** |
||
33 | * @var Failure $result |
||
34 | */ |
||
35 | throw new InvalidValue($result->getFirstError()->getMessage(), $result->getErrors()); |
||
36 | } |
||
37 | $this->ip = $ip; |
||
38 | } |
||
57 | } |