CreateLambda::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
namespace Desmond\functions\special;
3
use Desmond\functions\DesmondSpecialFunction;
4
use Desmond\data_types\LambdaType;
5
use Desmond\ArgumentHelper;
6
use Desmond\exceptions\ArgumentException;
7
8
class CreateLambda extends DesmondSpecialFunction
9
{
10
    use ArgumentHelper;
11
12 17
    public function run(array $args)
13
    {
14 17
        $this->expectArguments('lambda', [['Vector']], $args);
15 16
        if (!isset($args[1])) {
16 1
            throw new ArgumentException('"lambda" expects argument 1 to be a function body.');
17
        }
18 15
        return new LambdaType($this->eval, $args[0], $args[1]);
19
    }
20
}
21