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.

ChainMatcher   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 57
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addMatcher() 0 4 1
B match() 0 22 5
A canMatch() 0 4 1
1
<?php
2
3
namespace Coduo\PHPMatcher\Matcher;
4
5
use Coduo\ToString\StringConverter;
6
7
final class ChainMatcher extends Matcher
8
{
9
    /**
10
     * @var array|ValueMatcher[]
11
     */
12
    private $matchers;
13
14
    /**
15
     * @param array|ValueMatcher[] $matchers
16
     */
17
    public function __construct(array $matchers = array())
18
    {
19
        $this->matchers = $matchers;
20
    }
21
22
    /**
23
     * @param ValueMatcher $matcher
24
     */
25
    public function addMatcher(ValueMatcher $matcher)
26
    {
27
        $this->matchers[] = $matcher;
28
    }
29
30
    /**
31
     * {@inheritDoc}
32
     */
33
    public function match($value, $pattern)
34
    {
35
        foreach ($this->matchers as $propertyMatcher) {
36
            if ($propertyMatcher->canMatch($pattern)) {
37
                if (true === $propertyMatcher->match($value, $pattern)) {
38
                    return true;
39
                }
40
41
                $this->error = $propertyMatcher->getError();
42
            }
43
        }
44
45
        if (!isset($this->error)) {
46
            $this->error = sprintf(
47
                'Any matcher from chain can\'t match value "%s" to pattern "%s"',
48
                new StringConverter($value),
49
                new StringConverter($pattern)
50
            );
51
        }
52
53
        return false;
54
    }
55
56
    /**
57
     * {@inheritDoc}
58
     */
59
    public function canMatch($pattern)
60
    {
61
        return true;
62
    }
63
}
64