Conditions | 6 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 6.0073 |
Changes | 0 |
1 | <?php |
||
24 | 13 | public function getAst(Node\Node $b, $path = '') |
|
25 | { |
||
26 | $ret = array( |
||
27 | 13 | 'type' => str_replace('Zicht\Tool\Script\Node\\', '', get_class($b)) |
|
28 | 13 | ); |
|
29 | 13 | if ($b instanceof Node\Branch) { |
|
30 | 12 | if (count($b->nodes)) { |
|
31 | 11 | $ret['nodes'] = array(); |
|
32 | |||
33 | 11 | foreach ($b->nodes as $n) { |
|
34 | 11 | if (null === $n) { |
|
35 | 2 | $ret['nodes'][] = $n; |
|
36 | 2 | } else { |
|
37 | 11 | if (!$n instanceof Node\Node) { |
|
38 | throw new \InvalidArgumentException("Invalid child node in " . Util::toPhp($path)); |
||
39 | } |
||
40 | 11 | $ret['nodes'][] = $this->getAst($n); |
|
41 | } |
||
42 | 11 | } |
|
43 | 11 | } |
|
44 | 12 | } |
|
45 | |||
46 | 13 | return $ret; |
|
47 | } |
||
48 | } |
||
49 |