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 ( 01765c...2026ee )
by Matthew
11s
created

StdEnv::add()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Sphpeme\Env;
4
5
6
7
class StdEnv implements EnvInterface
8
{
9
    const MAPPING = [
10
        '#' => '+',
11
        '+' => 'add',
12
        '-' => 'subtract',
13
        '*' => 'multiply',
14
        '/' => 'divide',
15
        '>' => 'gt',
16
        '<' => 'lt',
17
        '<=' => 'lte',
18
        '>=' => 'gte',
19
        'eq?' => 'isEqual',
20
        'eqv?' => 'isEquiv',
21
        'list' => '_list'
22
    ];
23
24
    public function __isset($prop): bool
25
    {
26
        return (bool)$this->__get($prop);
27
    }
28
29
    public function __get(string $prop)
30
    {
31
        if (isset(static::MAPPING[$prop])) {
32
            return $this->__get(static::MAPPING[$prop]);
33
        }
34
35
        return \is_callable([$this, $prop])
36
            ? [$this, $prop]
37
            : $this->$prop;
38
    }
39
40
    public $pi = M_PI;
41
42
    public function _list(...$args)
43
    {
44
        return $args;
45
    }
46
47
    public function car(array $list)
48
    {
49
        return current($list);
50
    }
51
52
    public function cdr(array $list)
53
    {
54
        return \array_slice($list, 1);
55
    }
56
57
    public function display($arg)
58
    {
59
        if (is_scalar($arg) || method_exists($arg, '__toString')) {
60
            echo $arg;
61
        } else {
62
            var_export($arg);
63
        }
64
    }
65
66
    public function newline()
67
    {
68
        echo PHP_EOL;
69
    }
70
71
    public function add($first, ...$rest)
72
    {
73
        return $first + (\count($rest) > 1
74
                ? $this->add(...$rest)
0 ignored issues
show
Bug introduced by
$rest is expanded, but the parameter $first of Sphpeme\Env\StdEnv::add() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

74
                ? $this->add(/** @scrutinizer ignore-type */ ...$rest)
Loading history...
75
                : current($rest));
76
    }
77
78
    public function subtract($first, ...$rest)
79
    {
80
        return $first - (\count($rest) > 1
81
                ? $this->add(...$rest)
0 ignored issues
show
Bug introduced by
$rest is expanded, but the parameter $first of Sphpeme\Env\StdEnv::add() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

81
                ? $this->add(/** @scrutinizer ignore-type */ ...$rest)
Loading history...
82
                : current($rest));
83
    }
84
85
    public function multiply($first, ...$rest)
86
    {
87
        return $first * (\count($rest) > 1
88
                ? $this->multiply(...$rest)
0 ignored issues
show
Bug introduced by
$rest is expanded, but the parameter $first of Sphpeme\Env\StdEnv::multiply() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

88
                ? $this->multiply(/** @scrutinizer ignore-type */ ...$rest)
Loading history...
89
                : current($rest));
90
    }
91
92
    public function divide($a, $b)
93
    {
94
        return $a / $b;
95
    }
96
97
    public function gt($a, $b)
98
    {
99
        return $a > $b;
100
    }
101
102
    public function lt($a, $b)
103
    {
104
        return $a < $b;
105
    }
106
107
    public function gte($a, $b)
108
    {
109
        return $a >= $b;
110
    }
111
112
    public function lte($a, $b)
113
    {
114
        return $a <= $b;
115
    }
116
117
    public function isEqual($a, $b)
118
    {
119
        return $a == $b;
120
    }
121
122
    public function isEquiv($a, $b)
123
    {
124
        return $a === $b;
125
    }
126
}