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.

Evaluator::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
nc 5
nop 2
dl 0
loc 16
ccs 9
cts 9
cp 1
crap 4
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
namespace Sphpeme;
4
5
6
use Sphpeme\ExpHandler\ExpHandler;
7
use Sphpeme\ExpHandler\ScalarHandler;
8
use Sphpeme\ExpHandler\SymbolHandler;
9
10
class Evaluator
11
{
12
    /**
13
     * @var ExpHandler[]
14
     */
15
    private $handlers;
16
17 5
    public function __construct(ExpHandler ...$handlers)
18
    {
19 5
        if (\count($handlers) === 0) {
20
            $handlers = [
21 5
                new SymbolHandler(),
22 5
                new ScalarHandler(),
23
            ];
24
        }
25 5
        $this->handlers = $handlers;
26 5
    }
27
28 2
    public function __invoke($exp, Env\EnvInterface $env)
29
    {
30 2
        foreach ($this->handlers as $handler) {
31 2
            if ($handler->handles($exp)) {
32 2
                return $handler->evaluate($exp, $env, $this);
33
            }
34
        }
35
36 1
        $call = $this($exp[0], $env);
37 1
        $args = [];
38 1
        foreach (\array_slice($exp, 1) as $arg) {
39 1
            $args[] = $this($arg, $env);
40
        }
41
42 1
        return $call(...$args);
43
    }
44
}