src/Validator/EmailValidator.php
public function validateDomainPart($value, $send_errors = false)
    {
        // the domain name must be an IP address between brackets ...
        if (
            substr($value, 0, 1)=='[' &&
            substr($value, -1, 1)==']'
        ) {
            $ip_domain_part = substr($value, 1, strlen($value)-2);
            // is it an IPv6
            if (substr($ip_domain_part, 0, strlen('IPv6:'))=='IPv6:') {
                $ip6_domain_part = substr($ip_domain_part, strlen('IPv6:'));
                $ip6HostnameValidator = new InternetProtocolValidator('v6');
                try {
                    if (false===$ip6domain_name_valid = $ip6HostnameValidator->validate($ip6_domain_part, $send_errors)) {
                        return false;
                    }
                } catch (\Exception $e) {
                    throw $e;
                }
            }
            // otherwise IPv4
            else {
                $ip4HostnameValidator = new InternetProtocolValidator;
                try {
                    if (false===$ip4domain_name_valid = $ip4HostnameValidator->validate($ip_domain_part, $send_errors)) {
                        return false;
                    }
                } catch (\Exception $e) {
                    throw $e;
                }
            }
        }
        // ... or a valid hostname
        else {
            $hostnameValidator = new HostnameValidator;
            try {
                if (false===$hostdomain_name_valid = $hostnameValidator->validate($value, $send_errors)) {
                    return false;
                }
            } catch (\Exception $e) {
                throw $e;
            }
        }

        return true;
    }
public function validateDomainPart($value, $send_errors = false)
    {
        // the domain name must be an IP address between brackets ...
        if (
            substr($value, 0, 1)=='[' &&
            substr($value, -1, 1)==']'
        ) {
            $ip_domain_part = substr($value, 1, strlen($value)-2);
            // is it an IPv6
            if (substr($ip_domain_part, 0, strlen('IPv6:'))=='IPv6:') {
                $ip6_domain_part = substr($ip_domain_part, strlen('IPv6:'));
                $ip6HostnameValidator = new InternetProtocolValidator('v6');
                try {
                    if (false===$ip6domain_name_valid = $ip6HostnameValidator->validate($ip6_domain_part, $send_errors)) {
                        return false;
                    }
                } catch (\Exception $e) {
                    throw $e;
                }
            }
            // otherwise IPv4
            else {
                $ip4HostnameValidator = new InternetProtocolValidator;
                try {
                    if (false===$ip4domain_name_valid = $ip4HostnameValidator->validate($ip_domain_part, $send_errors)) {
                        return false;
                    }
                } catch (\Exception $e) {
                    throw $e;
                }
            }
        }
        // ... or a valid hostname
        else {
            $hostnameValidator = new HostnameValidator;
            try {
                if (false===$hostdomain_name_valid = $hostnameValidator->validate($value, $send_errors)) {
                    return false;
                }
            } catch (\Exception $e) {
                throw $e;
            }
        }

        return true;
    }
public function validateDomainPart ( $ value , $ send_errors = false ) { // the domain name must be an IP address between brackets ... if ( substr ( $ value , 0 , 1 ) == '[' && substr ( $ value , - 1 , 1 ) == ']' ) { $ ip_domain_part = substr ( $ value , 1 , strlen ( $ value ) - 2 ) ; // is it an IPv6 if ( substr ( $ ip_domain_part , 0 , strlen ( 'IPv6:' ) ) == 'IPv6:' ) { $ ip6_domain_part = substr ( $ ip_domain_part , strlen ( 'IPv6:' ) ) ; $ ip6HostnameValidator = new InternetProtocolValidator ( 'v6' ) ; try { if ( false === $ ip6domain_name_valid = $ ip6HostnameValidator -> validate ( $ ip6_domain_part , $ send_errors ) ) { return false ; } } catch ( \ Exception $ e ) { throw $ e ; } } // otherwise IPv4 else { $ ip4HostnameValidator = new InternetProtocolValidator ; try { if ( false === $ ip4domain_name_valid = $ ip4HostnameValidator -> validate ( $ ip_domain_part , $ send_errors ) ) { return false ; } } catch ( \ Exception $ e ) { throw $ e ; } } } // ... or a valid hostname else { $ hostnameValidator = new HostnameValidator ; try { if ( false === $ hostdomain_name_valid = $ hostnameValidator -> validate ( $ value , $ send_errors ) ) { return false ; } } catch ( \ Exception $ e ) { throw $ e ; } } return true ; }
Process domain part validation

@param   string  $value The domain part of an email address to validate
@param   bool    $send_errors Does the function must throw exceptions on validation failures ?
@return  bool    TRUE if $value pass the Email validation
@throws  \Exception for each invalid part if `$send_errors` is true
Process domain part validation