/**
* Compares two IPv4 addresses.
* In case a subnet is given, it checks if it contains the request IP.
*
* @param string $ip IPv4 address or subnet in CIDR notation
*
* @return bool Whether the request IP matches the IP, or whether the request IP is within the CIDR subnet
*/
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) {