IpAnonymizationUtility

Anonymize a given IP

Inspired by https://github.com/geertw/php-ip-anonymizer

Table of Contents

Constants

MASKV4  = [1 => '255.255.255.0', 2 => '255.255.0.0']
IPv4 netmask used to anonymize IPv4 address.
MASKV6  = [1 => 'ffff:ffff:ffff:ffff:0000:0000:0000:0000', 2 => 'ffff:ffff:ffff:0000:0000:0000:0000:0000']
IPv6 netmask used to anonymize IPv6 address.

Methods

anonymizeIp()  : string
Anonymize given IP

Constants

MASKV4

IPv4 netmask used to anonymize IPv4 address.

public array<int, string> MASKV4 = [1 => '255.255.255.0', 2 => '255.255.0.0']
  1. Mask host
  2. Mask host and subnet

MASKV6

IPv6 netmask used to anonymize IPv6 address.

public array<int, string> MASKV6 = [1 => 'ffff:ffff:ffff:ffff:0000:0000:0000:0000', 2 => 'ffff:ffff:ffff:0000:0000:0000:0000:0000']
  1. Mask Interface ID
  2. Mask Interface ID and SLA ID

Methods

anonymizeIp()

Anonymize given IP

public static anonymizeIp(string $address[, int $mask = null ]) : string
Parameters
$address : string

IP address

$mask : int = null

Allowed values are 0 (masking disabled), 1 (mask host), 2 (mask host and subnet)

Tags
throws
UnexpectedValueException
Return values
string

        
On this page

Search results