| Total Complexity | 5 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | final class IpAddress |
||
| 15 | { |
||
| 16 | private const IPV4_PARTS_COUNT = 4; |
||
| 17 | private const OBFUSCATED_OCTET = '0'; |
||
| 18 | public const LOCALHOST = '127.0.0.1'; |
||
| 19 | |||
| 20 | /** @var string */ |
||
| 21 | private $firstOctet; |
||
| 22 | /** @var string */ |
||
| 23 | private $secondOctet; |
||
| 24 | /** @var string */ |
||
| 25 | private $thirdOctet; |
||
| 26 | /** @var string */ |
||
| 27 | private $fourthOctet; |
||
| 28 | |||
| 29 | 12 | private function __construct(string $firstOctet, string $secondOctet, string $thirdOctet, string $fourthOctet) |
|
| 30 | { |
||
| 31 | 12 | $this->firstOctet = $firstOctet; |
|
| 32 | 12 | $this->secondOctet = $secondOctet; |
|
| 33 | 12 | $this->thirdOctet = $thirdOctet; |
|
| 34 | 12 | $this->fourthOctet = $fourthOctet; |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param string $address |
||
| 39 | * @return IpAddress |
||
| 40 | * @throws InvalidArgumentException |
||
| 41 | */ |
||
| 42 | 18 | public static function fromString(string $address): self |
|
| 51 | } |
||
| 52 | |||
| 53 | 6 | public function getObfuscatedCopy(): self |
|
| 60 | ); |
||
| 61 | } |
||
| 62 | |||
| 63 | 6 | public function __toString(): string |
|
| 73 |