src/RegisteredDomain.php
public function getRegisteredDomain($host)
    {
        $this->tree = $this->psl->getTree();

        $signingDomain = $this->normalizeHost($host);
        $signingDomainParts = explode('.', $signingDomain);

        $result = $this->findRegisteredDomain($signingDomainParts, $this->tree);

        if (empty($result)) {
            // this is an invalid domain name
            return null;
        }

        // assure there is at least 1 TLD in the stripped signing domain
        if (!strpos($result, '.')) {
            $cnt = count($signingDomainParts);
            if ($cnt == 1 || $signingDomainParts[$cnt-2] == '') {
                return null;
            }
            return $signingDomainParts[$cnt-2] . '.' . $signingDomainParts[$cnt-1];
        }
        return $result;
    }
public function getRegisteredDomain($host)
    {
        $this->tree = $this->psl->getTree();

        $signingDomain = $this->normalizeHost($host);
        $signingDomainParts = explode('.', $signingDomain);

        $result = $this->findRegisteredDomain($signingDomainParts, $this->tree);

        if (empty($result)) {
            // this is an invalid domain name
            return null;
        }

        // assure there is at least 1 TLD in the stripped signing domain
        if (!strpos($result, '.')) {
            $cnt = count($signingDomainParts);
            if ($cnt == 1 || $signingDomainParts[$cnt-2] == '') {
                return null;
            }
            return $signingDomainParts[$cnt-2] . '.' . $signingDomainParts[$cnt-1];
        }
        return $result;
    }
public function getRegisteredDomain ( $ host ) { $ this -> tree = $ this -> psl -> getTree ( ) ; $ signingDomain = $ this -> normalizeHost ( $ host ) ; $ signingDomainParts = explode ( '.' , $ signingDomain ) ; $ result = $ this -> findRegisteredDomain ( $ signingDomainParts , $ this -> tree ) ; if ( empty ( $ result ) ) { // this is an invalid domain name return null ; } // assure there is at least 1 TLD in the stripped signing domain if ( ! strpos ( $ result , '.' ) ) { $ cnt = count ( $ signingDomainParts ) ; if ( $ cnt == 1 || $ signingDomainParts [ $ cnt - 2 ] == '' ) { return null ; } return $ signingDomainParts [ $ cnt - 2 ] . '.' . $ signingDomainParts [ $ cnt - 1 ] ; } return $ result ; }
Determine the registered domain portion of the supplied host string

@param string $host a host name or URL containing a host name

@return string|null shortest registrable domain portion of the supplied host or null if invalid
Determine the registered domain portion of the supplied host string