Passed
Push — master ( 310acb...1a0150 )
by Scott
02:48
created

Quasiquote   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

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 implements 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]);
0 ignored issues
show
Bug introduced by
The property eval does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
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 6
                        $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
Bug introduced by
The property function does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The property currentEnv does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
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