| 1 | <?php |
||
| 12 | final class IpAddress |
||
| 13 | { |
||
| 14 | private const IPV4_PARTS_COUNT = 4; |
||
| 15 | private const OBFUSCATED_OCTET = '0'; |
||
| 16 | public const LOCALHOST = '127.0.0.1'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | private $firstOctet; |
||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private $secondOctet; |
||
| 26 | /** |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | private $thirdOctet; |
||
| 30 | /** |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | private $fourthOctet; |
||
| 34 | |||
| 35 | 4 | private function __construct(string $firstOctet, string $secondOctet, string $thirdOctet, string $fourthOctet) |
|
| 42 | |||
| 43 | /** |
||
| 44 | * @param string $address |
||
| 45 | * @return IpAddress |
||
| 46 | * @throws WrongIpException |
||
| 47 | */ |
||
| 48 | 4 | public static function fromString(string $address): self |
|
| 58 | |||
| 59 | 4 | public function getObfuscatedCopy(): self |
|
| 68 | |||
| 69 | 4 | public function __toString(): string |
|
| 78 | } |
||
| 79 |