| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 2.0054 |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | 5 | public static function fromString(string $address): self |
|
| 45 | { |
||
| 46 | 5 | $address = \trim($address); |
|
| 47 | 5 | $parts = \explode('.', $address); |
|
| 48 | 5 | if (\count($parts) !== self::IPV4_PARTS_COUNT) { |
|
| 49 | throw WrongIpException::fromIpAddress($address); |
||
| 50 | } |
||
| 51 | |||
| 52 | 5 | $instance = new self(); |
|
| 53 | 5 | $instance->isLocalhost = $address === self::LOCALHOST; |
|
| 54 | 5 | [$instance->firstOctet, $instance->secondOctet, $instance->thirdOctet, $instance->fourthOctet] = $parts; |
|
| 55 | 5 | return $instance; |
|
| 56 | } |
||
| 57 | |||
| 75 |