Documentation

Converter
in package

FinalYes

Table of Contents

Constants

IPV4_MAPPED_PREFIX  = '::ffff:'
IPV6_6TO4_PREFIX  = '2002:'
REGEXP_IPV4_HOST  = '/ (?(DEFINE) # . is missing as it is used to separate labels (?<hexadecimal>0x[[:xdigit:]]*) (?<octal>0[0-7]*) (?<decimal>\d+) (?<ipv4_part>(?:(?&hexadecimal)|(?&octal)|(?&decimal))*) ) ^(?:(?&ipv4_part)\.){0,3}(?&ipv4_part)\.?$ /x'
REGEXP_IPV4_NUMBER_PER_BASE  = ['/^0x(?<number>[[:xdigit:]]*)$/' => 16, '/^0(?<number>[0-7]*)$/' => 8, '/^(?<number>\d+)$/' => 10]

Properties

$calculator  : Calculator
$maxIPv4Number  : mixed

Methods

__construct()  : mixed
fromBCMath()  : self
Returns an instance using a Bcmath calculator.
fromEnvironment()  : self
Returns an instance using a detected calculator depending on the PHP environment.
fromGMP()  : self
Returns an instance using a GMP calculator.
fromNative()  : self
Returns an instance using a PHP native calculator (requires 64bits PHP).
isIpv4()  : bool
toDecimal()  : string|null
Tries to convert a IPv4 hexadecimal or a IPv4 octal notation into a IPv4 dot-decimal notation if possible otherwise returns null.
toHexadecimal()  : string|null
toIPv6Using6to4()  : string|null
toIPv6UsingMapping()  : string|null
toOctal()  : string|null
labelToNumber()  : mixed
Converts a domain label into a IPv4 integer part.
long2Ip()  : string
Generates the dot-decimal notation for IPv4.

Constants

IPV4_MAPPED_PREFIX

private mixed IPV4_MAPPED_PREFIX = '::ffff:'

IPV6_6TO4_PREFIX

private mixed IPV6_6TO4_PREFIX = '2002:'

REGEXP_IPV4_HOST

private mixed REGEXP_IPV4_HOST = '/ (?(DEFINE) # . is missing as it is used to separate labels (?<hexadecimal>0x[[:xdigit:]]*) (?<octal>0[0-7]*) (?<decimal>\d+) (?<ipv4_part>(?:(?&hexadecimal)|(?&octal)|(?&decimal))*) ) ^(?:(?&ipv4_part)\.){0,3}(?&ipv4_part)\.?$ /x'

REGEXP_IPV4_NUMBER_PER_BASE

private mixed REGEXP_IPV4_NUMBER_PER_BASE = ['/^0x(?<number>[[:xdigit:]]*)$/' => 16, '/^0(?<number>[0-7]*)$/' => 8, '/^(?<number>\d+)$/' => 10]

Properties

$maxIPv4Number read-only

private mixed $maxIPv4Number

Methods

fromBCMath()

Returns an instance using a Bcmath calculator.

public static fromBCMath() : self
Return values
self

fromEnvironment()

Returns an instance using a detected calculator depending on the PHP environment.

public static fromEnvironment() : self
Tags
throws
MissingFeature

If no Calculator implementing object can be used on the platform

codeCoverageIgnore
Return values
self

fromGMP()

Returns an instance using a GMP calculator.

public static fromGMP() : self
Return values
self

fromNative()

Returns an instance using a PHP native calculator (requires 64bits PHP).

public static fromNative() : self
Return values
self

toHexadecimal()

public toHexadecimal(Stringable|string|null $host) : string|null
Parameters
$host : Stringable|string|null
Return values
string|null

toIPv6Using6to4()

public toIPv6Using6to4(Stringable|string|null $host) : string|null
Parameters
$host : Stringable|string|null
Return values
string|null

toIPv6UsingMapping()

public toIPv6UsingMapping(Stringable|string|null $host) : string|null
Parameters
$host : Stringable|string|null
Return values
string|null

        
On this page

Search results