public static function checkIp4(string
$requestIp, string
$ip): bool
{ $cacheKey =
$requestIp.'-'.
$ip.'-v4';
if (null !==
$cacheValue = self::
getCacheResult($cacheKey)) { return $cacheValue;
} if (!
filter_var($requestIp, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4
)) { return self::
setCacheResult($cacheKey, false
);
} if (str_contains($ip, '/'
)) { [$address,
$netmask] =
explode('/',
$ip, 2
);
if ('0' ===
$netmask) { return self::
setCacheResult($cacheKey, false !==
filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4
));
} if ($netmask < 0 ||
$netmask > 32
) { return self::
setCacheResult($cacheKey, false
);
}