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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 38
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 5
lcom 2
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A handles() 0 4 1
A evaluate() 0 4 1
A makeIfExp() 0 11 2
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
}