Conditions | 2 |
Paths | 2 |
Total Lines | 9 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
42 | 18 | public static function fromString(string $address): self |
|
43 | { |
||
44 | 18 | $address = trim($address); |
|
45 | 18 | $parts = explode('.', $address); |
|
46 | 18 | if (count($parts) !== self::IPV4_PARTS_COUNT) { |
|
47 | 6 | throw new InvalidArgumentException(sprintf('Provided IP "%s" is invalid', $address)); |
|
48 | } |
||
49 | |||
50 | 12 | return new self(...$parts); |
|
51 | } |
||
73 |