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.

OneOf::getError()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander;
4
5
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander;
6
use Coduo\ToString\StringConverter;
7
8
final class OneOf implements PatternExpander
9
{
10
    /**
11
     * @var PatternExpander[]
12
     */
13
    protected $expanders;
14
15
    protected $error;
16
17
    public function __construct()
18
    {
19
        if (func_num_args() < 2) {
20
            throw new \InvalidArgumentException("OneOf expander require at least two expanders.");
21
        }
22
        foreach (func_get_args() as $argument) {
23
            if (!$argument instanceof PatternExpander) {
24
                throw new \InvalidArgumentException("OneOf expander require each argument to be a valid PatternExpander.");
25
            }
26
27
            $this->expanders[] = $argument;
28
        }
29
    }
30
31
    /**
32
     * @param $value
33
     * @return boolean
34
     */
35 View Code Duplication
    public function match($value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        foreach ($this->expanders as $expander) {
38
            if ($expander->match($value)) {
39
                return true;
40
            }
41
        }
42
43
        $this->error = sprintf("Any expander available in OneOf expander does not match \"%s\".", new StringConverter($value));
44
        return false;
45
    }
46
47
    /**
48
     * @return string|null
49
     */
50
    public function getError()
51
    {
52
        return $this->error;
53
    }
54
}
55