GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

IsEmail   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 1
dl 47
loc 47
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A match() 14 14 3
A getError() 4 4 1
A matchValue() 8 8 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 Coduo\PHPMatcher\Matcher\Pattern\Expander;
4
5
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6
use Coduo\ToString\StringConverter;
7
8 View Code Duplication
final class IsEmail implements PatternExpander
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * @var null|string
12
     */
13
    private $error;
14
15
    /**
16
     * @param string $value
17
     * @return boolean
18
     */
19
    public function match($value)
20
    {
21
        if (false === is_string($value)) {
22
            $this->error = sprintf("IsEmail expander require \"string\", got \"%s\".", new StringConverter($value));
23
            return false;
24
        }
25
26
        if (false === $this->matchValue($value)) {
27
            $this->error = sprintf("string \"%s\" is not a valid e-mail address.", $value);
28
            return false;
29
        }
30
31
        return true;
32
    }
33
34
    /**
35
     * @return string|null
36
     */
37
    public function getError()
38
    {
39
        return $this->error;
40
    }
41
42
    /**
43
     * @param string $value
44
     * @return bool
45
     */
46
    protected function matchValue($value)
47
    {
48
        try {
49
            return false !== filter_var($value, FILTER_VALIDATE_EMAIL);
50
        } catch (\Exception $e) {
51
            return false;
52
        }
53
    }
54
}
55