| 1 | <?php |
||
| 8 | final class IpAddress |
||
| 9 | { |
||
| 10 | private const IPV4_PARTS_COUNT = 4; |
||
| 11 | private const OBFUSCATED_OCTET = '0'; |
||
| 12 | public const LOCALHOST = '127.0.0.1'; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | private $firstOctet; |
||
| 18 | /** |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | private $secondOctet; |
||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private $thirdOctet; |
||
| 26 | /** |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | private $fourthOctet; |
||
| 30 | /** |
||
| 31 | * @var bool |
||
| 32 | */ |
||
| 33 | private $isLocalhost; |
||
| 34 | |||
| 35 | 5 | private function __construct() |
|
| 38 | |||
| 39 | /** |
||
| 40 | * @param string $address |
||
| 41 | * @return IpAddress |
||
| 42 | * @throws WrongIpException |
||
| 43 | */ |
||
| 44 | 5 | public static function fromString(string $address): self |
|
| 57 | |||
| 58 | 5 | public function getObfuscatedCopy(): self |
|
| 64 | |||
| 65 | 5 | public function __toString(): string |
|
| 74 | } |
||
| 75 |