src/Domain/Value/Identifier/Uri.php
protected static function isValidHost(string $host): bool
    {
        // http://tools.ietf.org/html/rfc3986#section-3.2.2
        // A host identified by an Internet Protocol literal address, version 6
        // [RFC3513] or later, is distinguished by enclosing the IP literal
        // within square brackets ("[" and "]").  This is the only place where
        // square bracket characters are allowed in the URI syntax.
        if (strpos($host, '[') !== false) {
            return static::isValidIpLiteral($host);
        }

        // IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
        $dec = '(?:(?:2[0-4]|1[0-9]|[1-9])?[0-9]|25[0-5])';
        $ipV4 = sprintf('/\A(?:%s\.){3}%s\z/', $dec, $dec);
        if (preg_match($ipV4, $host)) {
            return true;
        }

        // reg-name = *( unreserved / pct-encoded / sub-delims )
        $pattern = sprintf(
            '/\A(?:[%s%s]|(?:%s))*\z/',
            static::UNRESERVED_SET,
            static::SUB_DELIMS_SET,
            static::PCT_ENCODED_SET
        );

        return !!preg_match($pattern, $host);
    }
protected static function isValidHost(string $host): bool
    {
        // http://tools.ietf.org/html/rfc3986#section-3.2.2
        // A host identified by an Internet Protocol literal address, version 6
        // [RFC3513] or later, is distinguished by enclosing the IP literal
        // within square brackets ("[" and "]").  This is the only place where
        // square bracket characters are allowed in the URI syntax.
        if (strpos($host, '[') !== false) {
            return static::isValidIpLiteral($host);
        }

        // IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
        $dec = '(?:(?:2[0-4]|1[0-9]|[1-9])?[0-9]|25[0-5])';
        $ipV4 = sprintf('/\A(?:%s\.){3}%s\z/', $dec, $dec);
        if (preg_match($ipV4, $host)) {
            return true;
        }

        // reg-name = *( unreserved / pct-encoded / sub-delims )
        $pattern = sprintf(
            '/\A(?:[%s%s]|(?:%s))*\z/',
            static::UNRESERVED_SET,
            static::SUB_DELIMS_SET,
            static::PCT_ENCODED_SET
        );

        return !!preg_match($pattern, $host);
    }
protected static function isValidHost ( string $ host ) : bool { // http://tools.ietf.org/html/rfc3986#section-3.2.2 // A host identified by an Internet Protocol literal address, version 6 // [RFC3513] or later, is distinguished by enclosing the IP literal // within square brackets ("[" and "]").  This is the only place where // square bracket characters are allowed in the URI syntax. if ( strpos ( $ host , '[' ) !== false ) { return static :: isValidIpLiteral ( $ host ) ; } // IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet $ dec = '(?:(?:2[0-4]|1[0-9]|[1-9])?[0-9]|25[0-5])' ; $ ipV4 = sprintf ( '/\A(?:%s\.){3}%s\z/' , $ dec , $ dec ) ; if ( preg_match ( $ ipV4 , $ host ) ) { return true ; } // reg-name = *( unreserved / pct-encoded / sub-delims ) $ pattern = sprintf ( '/\A(?:[%s%s]|(?:%s))*\z/' , static :: UNRESERVED_SET , static :: SUB_DELIMS_SET , static :: PCT_ENCODED_SET ) ; return ! ! preg_match ( $ pattern , $ host ) ; }
Checks if a host is valid

@param string $host The host

@return bool
Checks if a host is valid