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
Pull Request — master (#7)
by Matthew
02:18
created

LetStarHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
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 LetStarHandler implements ExpHandler
11
{
12
13
14
    private $letStarSymbol;
15
    private $letSymbol;
16
17
    public function __construct()
18
    {
19
        $this->letStarSymbol = Symbol::make('let*');
20
        $this->letSymbol = Symbol::make('let');
21
    }
22
23
    public function handles($program): bool
24
    {
25
        return $program[0] === $this->letStarSymbol;
26
    }
27
28
    public function generateLet($program)
29
    {
30
        // bindings is an array of pairs: [[param, value], [param, value]]
31
        list($_letStar, $bindings) = $program;
32
        $body = \array_slice($program, 2);
33
34
        if (\count($bindings) > 1) {
35
            return [$this->letSymbol, [$bindings[0]],
36
                $this->generateLet(array_merge(
37
                    [$this->letStarSymbol, \array_slice($bindings, 1)],
38
                        $body))];
39
        }
40
41
        return array_merge(
42
            [$this->letSymbol, [$bindings[0]]],
43
            $body); // unpack the body of let into the lambda exp
44
45
    }
46
47
    public function evaluate($program, Env\EnvInterface $env, Evaluator $evaluate)
48
    {
49
        return $evaluate($this->generateLet($program), $env);
50
    }
51
}