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.
Passed
Push — master ( b46516...5bdfb8 )
by Matthew
02:09 queued 10s
created

CondHandler::handles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sphpeme\ExpHandler;
4
5
6
use Sphpeme\Env;
7
use Sphpeme\Evaluator;
8
use Sphpeme\Symbol;
9
10
class CondHandler implements ExpHandler
11
{
12
13
    private $condSymbol;
14
15
    private $ifSymbol;
16
17
    private $elseSymbol;
18
19 2
    public function __construct()
20
    {
21 2
        $this->elseSymbol = Symbol::make('else');
22 2
        $this->condSymbol = Symbol::make('cond');
23 2
        $this->ifSymbol = Symbol::make('if');
24 2
    }
25
26 1
    public function handles($program): bool
27
    {
28 1
        return $program[0] === $this->condSymbol;
29
    }
30
31 1
    public function evaluate($program, Env\EnvInterface $env, Evaluator $evaluate)
32
    {
33 1
        return $evaluate($this->makeIfExp(\array_slice($program, 1)), $env);
34
    }
35
36 1
    private function makeIfExp($conditions)
37
    {
38 1
        $pred = $conditions[0][0];
39
40 1
        if ($pred === $this->elseSymbol) {
41 1
            return $conditions[0][1];
42
        }
43
44 1
        return [$this->ifSymbol, $pred,
45 1
            $conditions[0][1], $this->makeIfExp(\array_slice($conditions, 1))];
46
    }
47
}