firstOctet = $firstOctet; $this->secondOctet = $secondOctet; $this->thirdOctet = $thirdOctet; $this->fourthOctet = $fourthOctet; } /** * @param string $address * @return IpAddress * @throws WrongIpException */ public static function fromString(string $address): self { $address = \trim($address); $parts = \explode('.', $address); if (\count($parts) !== self::IPV4_PARTS_COUNT) { throw WrongIpException::fromIpAddress($address); } return new self(...$parts); } public function getObfuscatedCopy(): self { return new self( $this->firstOctet, $this->secondOctet, $this->thirdOctet, self::OBFUSCATED_OCTET ); } public function __toString(): string { return \implode('.', [ $this->firstOctet, $this->secondOctet, $this->thirdOctet, $this->fourthOctet, ]); } }