Completed
Branch BUG-10489-non-trashed-regs-onl... (a7561f)
by
unknown
42:44 queued 32:08
created

WordPress   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 22
loc 22
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace EventEspresso\core\domain\services\validation\email\strategies;
4
5
use EventEspresso\core\domain\services\validation\email\EmailValidationException;
6
7
defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed');
8
9
10
11
/**
12
 * Class WordPressEmailValidation
13
 * Uses the WP core is_email() function to validate the email address.
14
 * Does not allow for International charsets.
15
 *
16
 * @package        Event Espresso
17
 * @author         Mike Nelson
18
 * @since          $VID:$
19
 */
20 View Code Duplication
class WordPress extends Basic
21
{
22
23
    /**
24
     *
25
     * @param string $email_address
26
     * @return boolean
27
     * @throws EmailValidationException
28
     */
29
    public function validate($email_address)
30
    {
31
        parent::validate($email_address);
32
        if( ! is_email($email_address)){
33
            throw new EmailValidationException(
34
                esc_html__('The email address provided is not valid.', 'event_espresso')
35
            );
36
        }
37
        return true;
38
    }
39
40
41
}
42
// End of file WordPressEmailValidation.php
43
// Location: core\services\validation/WordPressEmailValidation.php
44