\Symfony\Component\HttpFoundationIpUtils

Http utility functions.

Summary

Methods
Properties
Constants
checkIp()
checkIp4()
checkIp6()
anonymize()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
__construct()
$checkedIps
N/A

Properties

$checkedIps

$checkedIps

Methods

checkIp()

checkIp(?string  $requestIp, string|array  $ips) : bool

Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets.

Parameters

?string $requestIp
string|array $ips

List of IPs or subnets (can be a string if only a single one)

Returns

bool —

checkIp4()

checkIp4(?string  $requestIp, string  $ip) : bool

Compares two IPv4 addresses.

In case a subnet is given, it checks if it contains the request IP.

Parameters

?string $requestIp
string $ip

IPv4 address or subnet in CIDR notation

Returns

bool —

Whether the request IP matches the IP, or whether the request IP is within the CIDR subnet

checkIp6()

checkIp6(?string  $requestIp, string  $ip) : bool

Compares two IPv6 addresses.

In case a subnet is given, it checks if it contains the request IP.

Parameters

?string $requestIp
string $ip

IPv6 address or subnet in CIDR notation

Throws

\RuntimeException

When IPV6 support is not enabled

Returns

bool —

anonymize()

anonymize(string  $ip) : string

Anonymizes an IP/IPv6.

Removes the last byte for v4 and the last 8 bytes for v6 IPs

Parameters

string $ip

Returns

string —

__construct()

__construct() : mixed

This class should not be instantiated.

Returns

mixed —