Quasiquote   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 3
dl 0
loc 27
c 0
b 0
f 0
ccs 17
cts 17
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C run() 0 24 9
1
<?php
2
namespace Desmond\functions\special;
3
use Desmond\functions\DesmondSpecialFunction;
4
use Desmond\data_types\ListType;
5
6
class Quasiquote extends DesmondSpecialFunction
7
{
8 8
    public function run(array $args)
9
    {
10 8
        $arg = $args[0];
11 8
        $isList = $arg instanceof ListType;
12 8
        if ($isList && !empty($arg->value())) {
13 6
            $list = $arg;
14 6
            foreach ($list->value() as $index => $element) {
15 6
                if ($element->value() == 'unquote') {
16 2
                    $newValue = $this->eval->getReturn($list->rest()[0]);
17 2
                    $list = $newValue;
18
                }
19 6
                else if ($element instanceof ListType && !empty($element->value())) {
20 2
                    if ($element->first()->value() == 'unquote') {
21 1
                        $newValue = $this->eval->getReturn($element->rest()[0]);
22 1
                        $list->set($newValue, $index);
23
                    }
24
                }
25
            }
26
        }
27 8
        $quote = new Quote();
28 8
        return isset($list)
29 6
            ? $quote->run([$list], $this->function, $this->currentEnv, $this->eval)
0 ignored issues
show
Unused Code introduced by
The call to Quote::run() has too many arguments starting with $this->function.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
30 8
            : $quote->run($args, $this->function, $this->currentEnv, $this->eval);
0 ignored issues
show
Unused Code introduced by
The call to Quote::run() has too many arguments starting with $this->function.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
31
    }
32
}
33