Documentation

IpUtils
in package

Http utility functions.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

$checkedIps  : mixed
anonymize()  : string
Anonymizes an IP/IPv6.
checkIp()  : bool
Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets.
checkIp4()  : bool
Compares two IPv4 addresses.
checkIp6()  : bool
Compares two IPv6 addresses.
__construct()  : mixed
This class should not be instantiated.

Properties

$checkedIps

private static mixed $checkedIps = []

Methods

anonymize()

Anonymizes an IP/IPv6.

public static anonymize(string $ip) : string

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

Parameters
$ip : string
Return values
string

checkIp()

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

public static checkIp(string|null $requestIp, string|array<string|int, mixed> $ips) : bool
Parameters
$requestIp : string|null
$ips : string|array<string|int, mixed>

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

Return values
bool

checkIp4()

Compares two IPv4 addresses.

public static checkIp4(string|null $requestIp, string $ip) : bool

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

Parameters
$requestIp : string|null
$ip : string

IPv4 address or subnet in CIDR notation

Return values
bool

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

checkIp6()

Compares two IPv6 addresses.

public static checkIp6(string|null $requestIp, string $ip) : bool

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

Parameters
$requestIp : string|null
$ip : string

IPv6 address or subnet in CIDR notation

Tags
author

David Soria Parra

see
https://github.com/dsp/v6tools
throws
RuntimeException

When IPV6 support is not enabled

Return values
bool

__construct()

This class should not be instantiated.

private __construct() : mixed
Return values
mixed

Search results