toIPv4(); $ipv6Bytes = $parsedIp->getBytes(); if ($ipv4) { $ip = (string)$ipv4; } elseif (array_slice($ipv6Bytes, 0, 4) === [0x00, 0x64, 0xFF, 0x9B]) { $ip = (string)IPv4::fromBytes(array_slice($ipv6Bytes, -4, 4)); } else { $ip = (string)$parsedIp; } } else { $ip = (string)$parsedIp; } if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { /* Range address */ return true; } if (IpUtils::checkIp($ip, self::LOCAL_ADDRESS_RANGES)) { /* Within local range */ return true; } return false; } }