Passed
Branch master (7315b7)
by Scott
02:53
created

NamespaceBlock   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 28
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 23 3
1
<?php
2
namespace Desmond\functions\special;
3
use Desmond\DesmondNamespace as NS;
4
use Desmond\functions\DesmondSpecialFunction;
5
use Desmond\ArgumentHelper;
6
7
class NamespaceBlock extends DesmondSpecialFunction
8
{
9
    use ArgumentHelper;
10
11 7
    public function run(array $args)
12
    {
13 7
        $name = $args[0]->value();
14 7
        if (!NS::exists($name)) {
15 4
            $newEnv = $this->currentEnv->makeChild();
16 4
            $this->currentEnv = $this->currentEnv->values[$newEnv];
17 4
            NS::create($name, $this->currentEnv);
18
        } else {
19 5
            $this->currentEnv = NS::get($name);
20
        }
21
22
23 7
        $last = end($args);
24 7
        array_pop($args);
25 7
        array_shift($args);
26 7
        foreach($args as $arg) {
27 1
            $this->eval->getReturn($arg);
28
        }
29 7
        $return = $this->eval->getReturn($last);
30
31 7
        $this->currentEnv = $this->currentEnv->getParent();
32 7
        return $return;
33
    }
34
}
35