Converter
in package
FinalYes
Tags
Table of Contents
Constants
- MAX_DOMAIN_LENGTH = 253
- MAX_LABEL_LENGTH = 63
- REGEXP_IDNA_PATTERN = '/[^\x20-\x7f]/'
- REGEXP_REGISTERED_NAME = '/ (?(DEFINE) (?<unreserved>[a-z0-9_~\-]) # . is missing as it is used to separate labels (?<sub_delims>[!$&\'()*+,;=]) (?<encoded>%[A-F0-9]{2}) (?<reg_name>(?:(?&unreserved)|(?&sub_delims)|(?&encoded))*) ) ^(?:(?®_name)\.)*(?®_name)\.?$ /ix'
- General registered name regular expression.
Methods
- isIdn() : bool
- Tells whether the submitted host is a valid IDN regardless of its format.
- toAscii() : Result
- Converts the input to its IDNA ASCII form.
- toAsciiOrFail() : string
- Converts the input to its IDNA ASCII form or throw on failure.
- toUnicode() : Result
- Converts the input to its IDNA UNICODE form.
- toUnicodeOrFail() : string
- Converts the input to its IDNA UNICODE form or throw on failure.
- validateDomainAndLabelLength() : int
- Adapted from https://github.com/TRowbotham/idna.
Constants
MAX_DOMAIN_LENGTH
private
mixed
MAX_DOMAIN_LENGTH
= 253
MAX_LABEL_LENGTH
private
mixed
MAX_LABEL_LENGTH
= 63
REGEXP_IDNA_PATTERN
private
mixed
REGEXP_IDNA_PATTERN
= '/[^\x20-\x7f]/'
REGEXP_REGISTERED_NAME
General registered name regular expression.
private
mixed
REGEXP_REGISTERED_NAME
= '/
(?(DEFINE)
(?<unreserved>[a-z0-9_~\-]) # . is missing as it is used to separate labels
(?<sub_delims>[!$&\'()*+,;=])
(?<encoded>%[A-F0-9]{2})
(?<reg_name>(?:(?&unreserved)|(?&sub_delims)|(?&encoded))*)
)
^(?:(?®_name)\.)*(?®_name)\.?$
/ix'
Tags
Methods
isIdn()
Tells whether the submitted host is a valid IDN regardless of its format.
public
static isIdn(Stringable|string|null $domain) : bool
Returns false if the host is invalid or if its conversion yields the same result
Parameters
- $domain : Stringable|string|null
Return values
booltoAscii()
Converts the input to its IDNA ASCII form.
public
static toAscii(Stringable|string $domain[, Option|int|null $options = null ]) : Result
This method returns the string converted to IDN ASCII form
Parameters
- $domain : Stringable|string
- $options : Option|int|null = null
Tags
Return values
ResulttoAsciiOrFail()
Converts the input to its IDNA ASCII form or throw on failure.
public
static toAsciiOrFail(Stringable|string $domain[, Option|int|null $options = null ]) : string
Parameters
- $domain : Stringable|string
- $options : Option|int|null = null
Tags
Return values
stringtoUnicode()
Converts the input to its IDNA UNICODE form.
public
static toUnicode(Stringable|string $domain[, Option|int|null $options = null ]) : Result
This method returns the string converted to IDN UNICODE form
Parameters
- $domain : Stringable|string
- $options : Option|int|null = null
Tags
Return values
ResulttoUnicodeOrFail()
Converts the input to its IDNA UNICODE form or throw on failure.
public
static toUnicodeOrFail(Stringable|string $domain[, Option|int|null $options = null ]) : string
Parameters
- $domain : Stringable|string
- $options : Option|int|null = null
Tags
Return values
stringvalidateDomainAndLabelLength()
Adapted from https://github.com/TRowbotham/idna.
private
static validateDomainAndLabelLength(string $domain) : int
Parameters
- $domain : string