DefineSymbol   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 24
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 19 3
1
<?php
2
namespace Desmond\functions\special;
3
use Desmond\functions\DesmondSpecialFunction;
4
use Desmond\ArgumentHelper;
5
use Desmond\exceptions\ArgumentException;
6
use Desmond\data_types\LambdaType;
7
8
class DefineSymbol extends DesmondSpecialFunction
9
{
10
    use ArgumentHelper;
11
12 43
    public function run(array $args)
13
    {
14 43
        $this->expectArguments(
15 43
            'define',
16 43
            [0 => ['Symbol']],
17 43
            $args
18
        );
19 42
        if (!isset($args[1])) {
20 1
            throw new ArgumentException('"define" expects second argument.');
21
        }
22 41
        $value = $this->eval->getReturn($args[1]);
23 41
        $this->currentEnv->set($args[0]->value(), $value);
24
25
        // Update the lambda environment so that it can refer to itself.
26 41
        if ($value instanceof LambdaType) {
27 5
            $value->updateCreationEnv($this->currentEnv);
28
        }
29 41
        return $value;
30
    }
31
}
32