LimeSurvey API - Master branch

IpAddressAnonymizer

This class offers a function to anonymize ip addresses.

Class IpAddressAnonymizer

Table of Contents

Properties

$ipAddress  : string

Methods

__construct()  : mixed
IpAddressAnonymizer constructor.
anonymizeIpAddress()  : string|bool
Anonymizes ip address:
isIpv4()  : bool
Checks if ip is a valid ipv4
isIpv6()  : bool
Checks if ip is a valid ipv6
isValidIp()  : bool
Checks if ip is a valid ipAddress

Properties

Methods

__construct()

IpAddressAnonymizer constructor.

public __construct(string $ipAddress) : mixed
Parameters
$ipAddress : string

anonymizeIpAddress()

Anonymizes ip address:

public anonymizeIpAddress() : string|bool

For instance, the IPv4 address 192.168.178.123 is anonymized to 192.168.178.0. The IPv6 address 2a03:2880:2117:df07:face:b00c:5:1 is anonymized to 2a03:2880:2117:0:0:0:0:0 It also checks before anonymizes if it has already been anonymized and in that case give back the ip address without changing it.

Return values
string|bool

if ip is not anonymized false will be returned (in case of not a valid ip or ip has already been anonymized), else the anonymize ip will be returned as a string

isIpv4()

Checks if ip is a valid ipv4

public isIpv4() : bool
Return values
bool

true if it is ipv4, false otherwise

isIpv6()

Checks if ip is a valid ipv6

public isIpv6() : bool
Return values
bool

true if ipv6 is valid, false otherwise

isValidIp()

Checks if ip is a valid ipAddress

public isValidIp() : bool
Return values
bool

        
On this page

Search results