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.

Sequence::scan()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 1
dl 0
loc 23
ccs 17
cts 17
cp 1
crap 4
rs 9.552
c 0
b 0
f 0
1
<?php
2
namespace GetSky\ParserExpressions\Rules;
3
4
use GetSky\ParserExpressions\Context;
5
use GetSky\ParserExpressions\Result;
6
7
/**
8
 * The sequence operator e1 e2 first invokes e1, and if e1 succeeds,
9
 * subsequently invokes e2 on the remainder of the input string leftc
10
 * unconsumed by e1, and returns the result. If either e1 or e2 fails,
11
 * then the sequence expression e1 e2 fails.
12
 *
13
 * @package GetSky\ParserExpressions\Rules
14
 * @author  Alexander Getmanskii <[email protected]>
15
 */
16
class Sequence extends AbstractRule
17
{
18
19
    /**
20
     * @var \GetSky\ParserExpressions\RuleInterface[] Array with subrules.
21
     */
22
    protected $rules;
23
24
    /**
25
     * @param array $rules Array with subrules
26
     * @param string $name
27
     * @param callable $action
28
     */
29 4
    public function __construct(array $rules, $name = "Sequence", callable $action = null)
30
    {
31 4
        foreach ($rules as $rule) {
32 4
            $this->rules[] = $this->toRule($rule);
33
        }
34 4
        $this->name = (string) $name;
35 4
        $this->action = $action;
36 4
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 1
    public function scan(Context $context)
42
    {
43 1
        $index = $context->getCursor();
44 1
        $string = '';
45 1
        $result = new Result($this->name);
46
47 1
        $context->increaseDepth();
48 1
        foreach ($this->rules as $rule) {
49 1
            $value = $rule->scan($context);
50 1
            if ($value === false) {
51 1
                $context->setCursor($index);
52 1
                return false;
53 1
            } elseif ($value instanceof Result) {
54 1
                $string .= $value->getValue();
55 1
                $result->addChild($value);
56
            }
57
        }
58 1
        $context->decreaseDepth();
59 1
        $result->setValue($string, $index);
60 1
        $this->action($result);
61
62 1
        return $result;
63
    }
64
}
65