@@ -8,16 +8,16 @@ discard block |
||
| 8 | 8 | * @since 4.6 |
| 9 | 9 | * |
| 10 | 10 | */ |
| 11 | -class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy{ |
|
| 11 | +class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @param null $validation_error_message |
| 15 | 15 | */ |
| 16 | - public function __construct( $validation_error_message = NULL ) { |
|
| 17 | - if( ! $validation_error_message ){ |
|
| 16 | + public function __construct($validation_error_message = NULL) { |
|
| 17 | + if ( ! $validation_error_message) { |
|
| 18 | 18 | $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
| 19 | 19 | } |
| 20 | - parent::__construct( $validation_error_message ); |
|
| 20 | + parent::__construct($validation_error_message); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | * @return bool |
| 30 | 30 | * @throws \EE_Validation_Error |
| 31 | 31 | */ |
| 32 | - function validate( $normalized_value ) { |
|
| 33 | - if( $normalized_value && ! $this->_validate_email( $normalized_value ) ){ |
|
| 34 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'required'); |
|
| 32 | + function validate($normalized_value) { |
|
| 33 | + if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
| 34 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | /** |
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | - function get_jquery_validation_rule_array(){ |
|
| 44 | - return array( 'email'=>true, 'messages' => array( 'email' => $this->get_validation_error_message() ) ); |
|
| 43 | + function get_jquery_validation_rule_array() { |
|
| 44 | + return array('email'=>true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -54,34 +54,34 @@ discard block |
||
| 54 | 54 | * @return bool of whether the email is valid or not |
| 55 | 55 | * @throws \EE_Validation_Error |
| 56 | 56 | */ |
| 57 | - private function _validate_email( $email ) { |
|
| 58 | - if ( ! preg_match( '/^.+\@\S+\.\S+$/', $email ) ) { |
|
| 57 | + private function _validate_email($email) { |
|
| 58 | + if ( ! preg_match('/^.+\@\S+\.\S+$/', $email)) { |
|
| 59 | 59 | // email not in correct {string}@{string}.{string} format |
| 60 | 60 | return false; |
| 61 | 61 | } else { |
| 62 | - $atIndex = strrpos( $email, "@" ); |
|
| 63 | - $domain = substr( $email, $atIndex + 1 ); |
|
| 64 | - $local = substr( $email, 0, $atIndex ); |
|
| 65 | - $localLen = strlen( $local ); |
|
| 66 | - $domainLen = strlen( $domain ); |
|
| 67 | - if ( $localLen < 1 || $localLen > 64 ) { |
|
| 62 | + $atIndex = strrpos($email, "@"); |
|
| 63 | + $domain = substr($email, $atIndex + 1); |
|
| 64 | + $local = substr($email, 0, $atIndex); |
|
| 65 | + $localLen = strlen($local); |
|
| 66 | + $domainLen = strlen($domain); |
|
| 67 | + if ($localLen < 1 || $localLen > 64) { |
|
| 68 | 68 | // local part length exceeded |
| 69 | 69 | return false; |
| 70 | - } else if ( $domainLen < 1 || $domainLen > 255 ) { |
|
| 70 | + } else if ($domainLen < 1 || $domainLen > 255) { |
|
| 71 | 71 | // domain part length exceeded |
| 72 | 72 | return false; |
| 73 | - } else if ( $local[ 0 ] == '.' || $local[ $localLen - 1 ] == '.' ) { |
|
| 73 | + } else if ($local[0] == '.' || $local[$localLen - 1] == '.') { |
|
| 74 | 74 | // local part starts or ends with '.' |
| 75 | 75 | return false; |
| 76 | - } else if ( preg_match( '/\\.\\./', $local ) ) { |
|
| 76 | + } else if (preg_match('/\\.\\./', $local)) { |
|
| 77 | 77 | // local part has two consecutive dots |
| 78 | 78 | return false; |
| 79 | - } else if ( preg_match( '/\\.\\./', $domain ) ) { |
|
| 79 | + } else if (preg_match('/\\.\\./', $domain)) { |
|
| 80 | 80 | // domain part has two consecutive dots |
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | - if ( apply_filters( 'FHEE__EE_Email_Validation_Strategy___validate_email__perform_dns_checks', true ) ) { |
|
| 84 | - if ( ! checkdnsrr( $domain, "MX" ) ) { |
|
| 83 | + if (apply_filters('FHEE__EE_Email_Validation_Strategy___validate_email__perform_dns_checks', true)) { |
|
| 84 | + if ( ! checkdnsrr($domain, "MX")) { |
|
| 85 | 85 | // domain not found in MX records |
| 86 | 86 | throw new EE_Validation_Error( |
| 87 | 87 | __( |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | 'event_espresso' |
| 90 | 90 | ) |
| 91 | 91 | ); |
| 92 | - } else if ( ! checkdnsrr( $domain, "A" ) ) { |
|
| 92 | + } else if ( ! checkdnsrr($domain, "A")) { |
|
| 93 | 93 | // domain not found in A records |
| 94 | 94 | throw new EE_Validation_Error( |
| 95 | 95 | __( |