Domain name value object
$domain = new \Rincler\Domain('sub.domain.com');
echo $domain; // sub.domain.com
echo $domain->getIdn(); // sub.domain.com
echo $domain->getPunycode(); // sub.domain.com
echo $domain->getZone(); // domain.com
echo $domain->getWithoutZone(); // sub
echo $domain->getTld(); // com
echo $domain->getWithoutTld(); // sub.domain
echo $domain->getLevel(); // 3
$domain = new \Rincler\Domain('домен.рф');
echo $domain->getIdn(); // домен.рф
echo $domain->getPunycode(); // xn--d1acufc.xn--p1ai
$domain = new \Rincler\Domain('xn--d1acufc.xn--p1ai');
echo $domain->getIdn(); // домен.рф
echo $domain->getPunycode(); // xn--d1acufc.xnn
composer require rincler/domain
- static
isValid
- Returnstrue
if domain is valid, returnsfalse
otherwise (bool
) __constructor
- The constructor validates domain (throws exception if domain is not valid or domain ends with dot) and creates object of domaingetIdn
- Returns domain as IDN string (string
)getPunycode
- Returns domain as Punycode string (string
)getLevel
- Returns domain levels count (int
)getZone
- Returns zone of domain (\Rincler\Domain
)getWithoutZone
- Returns domain without zone (\Rincler\Domain
)getTld
- Returns top-level domain (\Rincler\Domain
)getWithoutTld
- Returns domain without top-level domain (\Rincler\Domain
)equals
- Returnstrue
if current domain equals checked domain, returnsfalse
otherwise (bool
)__toString
- Analog forgetIdn