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 ( 87ff31...63de6d )
by Norbert
9s
created

OrMatcher::match()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
rs 9.4285
cc 3
eloc 6
nc 3
nop 2
1
<?php
2
3
namespace Coduo\PHPMatcher\Matcher;
4
5
final class OrMatcher extends Matcher
6
{
7
    const MATCH_PATTERN = "/\|\|/";
8
9
    /**
10
     * @var ChainMatcher
11
     */
12
    private $chainMatcher;
13
14
    /**
15
     * @param ChainMatcher $chainMatcher
16
     */
17
    public function __construct(ChainMatcher $chainMatcher)
18
    {
19
        $this->chainMatcher = $chainMatcher;
20
    }
21
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function match($value, $pattern)
26
    {
27
        $patterns = explode('||', $pattern);
28
        foreach ($patterns as $childPattern) {
29
            if ($this->matchChild($value, $childPattern)){
30
                return true;
31
            }
32
        }
33
34
        return false;
35
    }
36
37
    /**
38
     * Matches single pattern
39
     *
40
     * @param $value
41
     * @param $pattern
42
     * @return bool
43
     */
44
    private function matchChild($value, $pattern)
45
    {
46
        if (!$this->chainMatcher->canMatch($pattern)) {
47
            return false;
48
        }
49
50
        if ($this->chainMatcher->match($value, $pattern)) {
51
            return true;
52
        }
53
54
        return false;
55
    }
56
57
    /**
58
     * {@inheritDoc}
59
     */
60
    public function canMatch($pattern)
61
    {
62
        return is_string($pattern) && 0 !== preg_match_all(self::MATCH_PATTERN, $pattern, $matches);
63
    }
64
}
65