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 ( be8573...dc3494 )
by Matthew
01:36
created

LetHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A evaluate() 0 9 1
A handles() 0 3 1
1
<?php
2
3
namespace Sphpeme\ExpHandler;
4
5
6
use Sphpeme\Env;
7
use Sphpeme\Evaluator;
8
use Sphpeme\Symbol;
9
10
class LetHandler implements ExpHandler
11
{
12
13
14
    private $letSymbol;
15
    private $lambdaSymbol;
16
17
    public function __construct()
18
    {
19
        $this->letSymbol = Symbol::make('let');
20
        $this->lambdaSymbol = Symbol::make('lambda');
21
    }
22
23
    public function handles($program): bool
24
    {
25
        return $program[0] === $this->letSymbol;
26
    }
27
28
    public function evaluate($program, Env\EnvInterface $env, Evaluator $evaluate)
29
    {
30
        // bindings is an array of pairs: [[param, value], [param, value]]
31
        list($_let, $bindings) = $program;
32
        $letBody = \array_slice($program, 2);
33
        $lambdaExp = array_merge(
34
            [$this->lambdaSymbol, array_column($bindings, 0)],
35
            $letBody); // unpack the body of let into the lambda exp
36
        return $evaluate(array_merge([$lambdaExp], array_column($bindings, 1)), $env);
37
    }
38
}