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.

AnyOf::scan()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 19
ccs 13
cts 13
cp 1
crap 3
rs 9.6333
c 0
b 0
f 0
1
<?php
2
/**
3
 * @package GetSky\ParserExpressions\Rules
4
 * @author  Alexander Getmanskii <[email protected]>
5
 */
6
namespace GetSky\ParserExpressions\Rules;
7
8
use GetSky\ParserExpressions\Context;
9
use GetSky\ParserExpressions\Result;
10
11
/**
12
 * The rule matching a single character out of a given characters set.
13
 */
14
class AnyOf extends AbstractRule
15
{
16
17
    /**
18
     * @var string String with characters.
19
     */
20
    protected $rule;
21
22
    /**
23
     * @var string
24
     */
25
    protected $name;
26
27
    /**
28
     * @param string $rule String with characters.
29
     * @param string $name Label for rule.
30
     * @param callable $action
31
     */
32 1
    public function __construct($rule, $name = "AnyOf", callable $action = null)
33
    {
34 1
        $this->rule = (string) $rule;
35 1
        $this->name = (string) $name;
36 1
        $this->action = $action;
37 1
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 1
    public function scan(Context $context)
43
    {
44 1
        $index = $context->getCursor();
45 1
        $len = strlen($this->rule);
46 1
        $char = $context->value();
47 1
        for ($i = 0; $i < $len; ++$i) {
48 1
            if ($char === $this->rule{$i}) {
49 1
                $result = new Result($this->name);
50 1
                $result->setValue($char, $index);
51 1
                $this->action($result);
52
53 1
                return $result;
54
            }
55
        };
56
57 1
        $context->setCursor($index);
58 1
        $context->error($this, $index);
59 1
        return false;
60
    }
61
}
62