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 ( d9bb99...49fd78 )
by Matthew
01:35
created

LambdaExpHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A evaluate() 0 5 1
A handles() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace Sphpeme\ExpHandler;
4
5
6
use Sphpeme\Env;
7
use function Sphpeme\env_extend;
0 ignored issues
show
introduced by
The function Sphpeme\env_extend was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
8
use Sphpeme\Evaluator;
9
use Sphpeme\Symbol;
10
11
class LambdaExpHandler implements ExpHandler
12
{
13
    private $lambdaSymbol;
14
15
    public function __construct()
16
    {
17
        $this->lambdaSymbol = Symbol::make('lambda');
18
    }
19
20
    public function evaluate($exp, Env $env, Evaluator $evaluate)
21
    {
22
        [$lambda, $params, $body] = $exp;
23
        return function (...$args) use ($env, $body, $params, $evaluate) {
24
            return $evaluate($body, env_extend($env, array_combine($params, $args)));
25
        };
26
    }
27
28
    public function handles($exp): bool
29
    {
30
        return $exp[0] === $this->lambdaSymbol;
31
    }
32
}