Download the PHP package rincler/domain without Composer
On this page you can find all versions of the php package rincler/domain. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package domain
Domain
A domain name value object that supports IDN and Punycode, FQDN, validates input, and provides easy access to the domain level, labels, zone, TLD, eTLD and eTLD+1.
Usage
Installation
Documentation
- static
isValid(): bool
- Returnstrue
if the domain is valid,false
otherwise. __constructor(string $domain)
- The constructor validates the domain and throwsInvalidDomainException
if it is not valid, then creates the value object.asIDN(): string
- Returns the domain in IDN format.asPunycode(): string
- Returns the domain in Punycode format.equals(Domain $domain): bool
- Returnstrue
if the current domain equals the specified domain,false
otherwise.level(): int
- Returns the number of levels in the domain.zone(): Domain
- Returns the domain zone.TLD(): Domain
- Returns the domain’s top-level domain (TLD).eTLD(): ?Domain
- Returns the domain’s effective top-level domain (eTLD).eTLDPlusOne(): ?Domain
- Returns the domain’s effective top-level domain plus the next label (eTLD+1).without(Domain $suffix): ?Domain
- Returns the domain without the specified suffix.labels(): Domain[]
- Returns an array containing all labels of the domain.label(int $level): Domain
- Returns the label corresponding to the given domain level.sliceToLevel(int $level): Domain
- Returns the domain up to the specified level.absolute(): Domain
- Returns the absolute form of the domain (FQDN) with a trailing dot.isAbsolute(): bool
- Returnstrue
if the domain is absolute (FQDN),false
otherwise.FQDN(): Domain
- Alias forabsolute()
.isFQDN(): bool
- Alias forisAbsolute()
.relative(): Domain
- Returns the relative form of the domain.isRoot(): bool
- Returnstrue
if the domain is root,false
otherwise.clone(): Domain
- Returns a copy of the domain.__toString(): string
- Magic method returning the domain equivalent toasIDN()
.
URL Domain
Domains used in URLs cannot be absolute (with a dot at the end) and do not have a root zone.
In such cases, you can use the UrlDomain
class instead of Domain
.
eTLD
See eTLD and Public Suffix List.
To use eTLDs, you must specify an eTLD provider via the eTLDSetProvider
method:
Why PHP >= 7.3?
Domain validation in the intl extension was fixed in 7.3.0. See http://bugs.php.net/76829
Development
Running tests in Docker:
-
Build the Docker image:
- Run the tests:
License
This library is released under the MIT license.
All versions of domain with dependencies
ext-intl Version *
ext-mbstring Version *