Completed
Branch FET-9222-rest-api-writes (b69541)
by
unknown
25:55 queued 14:06
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\services\validation\strategies;
4
5
use EventEspresso\core\domain\services\validation\EmailValidationException;
6
7
defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed');
8
9
10
11
/**
12
 * Class WordPressEmailValidation
13
 * Description
14
 *
15
 * @package        Event Espresso
16
 * @author         Mike Nelson
17
 * @since          $VID:$
18
 */
19 View Code Duplication
class WordPress extends Basic
20
{
21
22
    /**
23
     *
24
     * @param $input
25
     * @return boolean
26
     * @throws EmailValidationException
27
     */
28
    public function validate($input)
29
    {
30
        parent::validate($input);
31
        if( ! is_email($input)){
32
            throw new EmailValidationException(
33
                esc_html__('The email address provided is not valid.', 'event_espresso')
34
            );
35
        }
36
        return true;
37
    }
38
39
40
}
41
// End of file WordPressEmailValidation.php
42
// Location: core\services\validation/WordPressEmailValidation.php