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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 48
ccs 18
cts 18
cp 1
rs 10
wmc 4
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A scan() 0 19 3
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