/** * Returns a list with the specified level * * @param integer $intLevel 1 or greater * * @return array */ public function getLevel($intLevel = 1) { if (!is_int($intLevel) || $intLevel <= 0) { throw new InvalidArgumentException('Received wrong input value'); } $arrResults = array(); foreach ($this->get() as $strTld) { if (TldUtils::getLevel($strTld) != $intLevel) { continue; } $arrResults[] = $strTld; } return $arrResults; }
/** * Check domain name * * @see Domain::__construct * @param string $strDomainName * @param boolean $booIntranet * * @return boolean */ public static function isValid($strDomainName, $booIntranet = false) { $arrCheckList = explode('.', $strDomainName); foreach ($arrCheckList as $strTmpName) { if (preg_match('/^[0-9a-z\\-]+$/i', $strTmpName) < 1 || preg_match('/(^\\-|\\-$)/', $strTmpName) === 1 || strpos($strDomainName, '.') === false) { return false; } } // endforeach if (preg_match('/^(?P<part>[[:alnum:]]([[:alnum:]\\-]*[[:alnum:]])?)(\\.(?&part))+$/i', $strDomainName) !== 1) { return false; } if (!TldUtils::isValid(array_pop($arrCheckList), $booIntranet)) { return false; } return true; }
/** * Is this domain subdomain * * @return boolean */ public function isSubdomain() { if (TldUtils::isValid($this->getTldNameOrSubdomainName(), $this->isIntranet())) { return false; } return true; }