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.

Code Duplication    Length = 47-48 lines in 3 locations

src/Matcher/Pattern/Expander/IsDateTime.php 1 location

@@ 8-55 (lines=48) @@
5
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6
use Coduo\ToString\StringConverter;
7
8
final class IsDateTime implements PatternExpander
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("IsDateTime 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 date.", $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
            new \DateTime($value);
50
            return true;
51
        } catch (\Exception $e) {
52
            return false;
53
        }
54
    }
55
}
56

src/Matcher/Pattern/Expander/IsEmail.php 1 location

@@ 8-54 (lines=47) @@
5
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6
use Coduo\ToString\StringConverter;
7
8
final class IsEmail implements PatternExpander
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

src/Matcher/Pattern/Expander/IsUrl.php 1 location

@@ 8-54 (lines=47) @@
5
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6
use Coduo\ToString\StringConverter;
7
8
final class IsUrl implements PatternExpander
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("IsUrl 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 URL.", $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_URL);
50
        } catch (\Exception $e) {
51
            return false;
52
        }
53
    }
54
}
55