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.

LetStarHandler   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 42
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handles() 0 4 1
A generateLet() 0 18 2
A evaluate() 0 4 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 LetStarHandler implements ExpHandler
11
{
12
13
14
    private $letStarSymbol;
15
    private $letSymbol;
16
17 2
    public function __construct()
18
    {
19 2
        $this->letStarSymbol = Symbol::make('let*');
20 2
        $this->letSymbol = Symbol::make('let');
21 2
    }
22
23 1
    public function handles($program): bool
24
    {
25 1
        return $program[0] === $this->letStarSymbol;
26
    }
27
28 1
    public function generateLet($program)
29
    {
30
        // bindings is an array of pairs: [[param, value], [param, value]]
31 1
        list($_letStar, $bindings) = $program;
0 ignored issues
show
Unused Code introduced by
The assignment to $_letStar is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
32 1
        $body = \array_slice($program, 2);
33
34 1
        if (\count($bindings) > 1) {
35 1
            return [$this->letSymbol, [$bindings[0]],
36 1
                $this->generateLet(array_merge(
37 1
                    [$this->letStarSymbol, \array_slice($bindings, 1)],
38 1
                        $body))];
39
        }
40
41 1
        return array_merge(
42 1
            [$this->letSymbol, [$bindings[0]]],
43 1
            $body); // unpack the body of let into the lambda exp
44
45
    }
46
47 1
    public function evaluate($program, Env\EnvInterface $env, Evaluator $evaluate)
48
    {
49 1
        return $evaluate($this->generateLet($program), $env);
50
    }
51
}