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.
Completed
Push — master ( 615247...80ce76 )
by Norbert
03:14
created

UuidMatcher::canMatch()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 1
1
<?php
2
3
namespace Coduo\PHPMatcher\Matcher;
4
5
use Coduo\ToString\StringConverter;
6
7
final class UuidMatcher extends Matcher
8
{
9
    const UUID_PATTERN = '/^@uuid@$/';
10
    const UUID_FORMAT_PATTERN = '|^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$|';
11
12
    /**
13
     * {@inheritDoc}
14
     */
15
    public function match($value, $pattern)
16
    {
17
        if (!is_string($value)) {
18
            $this->error = sprintf(
19
                "%s \"%s\" is not a valid UUID: not a string.",
20
                gettype($value),
21
                new StringConverter($value)
22
            );
23
            return false;
24
        }
25
26
        if (1 !== preg_match(self::UUID_FORMAT_PATTERN, $value)) {
27
            $this->error = sprintf(
28
                "%s \"%s\" is not a valid UUID: invalid format.",
29
                gettype($value),
30
                $value
31
            );
32
            return false;
33
        }
34
35
        return true;
36
    }
37
38
    /**
39
     * {@inheritDoc}
40
     */
41
    public function canMatch($pattern)
42
    {
43
        return is_string($pattern) && 0 !== preg_match(self::UUID_PATTERN, $pattern);
44
    }
45
}
46