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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A match() 0 22 3
A canMatch() 0 4 2
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