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.
Completed
Push — master ( 4905bb...351df2 )
by Matthew
12s
created

NamedLetHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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 NamedLetHandler implements ExpHandler
11
{
12
13
14
    /** @var Symbol */
15
    private $letSymbol;
16
17
    public function __construct()
18
    {
19
        $this->letSymbol = Symbol::make('let');
20
    }
21
22
    public function handles($program): bool
23
    {
24
        return $program[0] === $this->letSymbol &&
25
            $program[1] instanceof Symbol;
26
    }
27
28
    public function evaluate($program, Env\EnvInterface $env, Evaluator $evaluate)
29
    {
30
        // generate a lambda (eval the program *without* name)
31
        // use that as the value in the define
32
        // then call that
33
        list($_let, $name, $bindings) = $program;
34
        $body = \array_slice($program, 3);
35
        $lambdaExp = array_merge([Symbol::make('lambda'), array_column($bindings, 0)], $body);
36
        $defineExp = [Symbol::make('define'), $name, $lambdaExp];
37
        $evaluate($defineExp, $env);
38
        return $evaluate(array_merge([$name], array_column($bindings, 1)), $env);
39
    }
40
}