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.

AbstractRule::scan()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 1
dl 0
loc 1
c 0
b 0
f 0
ccs 0
cts 0
cp 0
1
<?php
2
namespace GetSky\ParserExpressions\Rules;
3
4
use GetSky\ParserExpressions\Context;
5
use GetSky\ParserExpressions\Result;
6
use GetSky\ParserExpressions\RuleInterface;
7
8
/**
9
 * Abstract class that contains the method of reduction to the rule.
10
 *
11
 * @package GetSky\ParserExpressions\Rules
12
 * @author  Alexander Getmanskii <[email protected]>
13
 */
14
abstract class AbstractRule implements RuleInterface
15
{
16
    /**
17
     * @var string The label for the rule.
18
     */
19
    protected $name;
20
21
    /**
22
     * @var callable The function which is performed after scanning.
23
     */
24
    protected $action;
25
26
    /**
27
     * Returns the value of the label.
28
     *
29
     * @return string
30
     */
31 1
    public function getName()
32
    {
33 1
        return $this->name;
34
    }
35
36
    /**
37
     * Launches action.
38
     *
39
     * @param Result $result
40
     * @return void
41
     */
42 8
    public function action(Result $result = null)
43
    {
44 8
        if ($this->action !== null) {
45 1
            $action = $this->action;
46 1
            $action($result);
47
        }
48 8
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    abstract public function scan(Context $context);
54
55
    /**
56
     * This method converts the input value to an object that implements an interface Rule.
57
     *
58
     * @param $rule
59
     * @return RuleInterface
60
     */
61 12
    public function toRule($rule)
62
    {
63 12
        if ($rule instanceof RuleInterface) {
64 12
            return $rule;
65
        }
66 1
        if (is_array($rule)) {
67 1
            return new Sequence($rule);
68
        }
69 1
        return new Row($rule);
70
    }
71
}
72