Script   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 39
ccs 0
cts 25
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C compile() 0 30 7
1
<?php
2
/**
3
 * For licensing information, please see the LICENSE file accompanied with this file.
4
 *
5
 * @author Gerard van Helden <[email protected]>
6
 * @copyright 2012 Gerard van Helden <http://melp.nl>
7
 */
8
9
namespace Zicht\Tool\Script\Node;
10
11
use Zicht\Tool\Script\Buffer;
12
13
/**
14
 * A Script node is used as the body for each of the nodes executed in a pre, do, or post section in a Task
15
 */
16
class Script extends Branch
17
{
18
    /**
19
     * Compiles the node.
20
     *
21
     * @param \Zicht\Tool\Script\Buffer $buffer
22
     * @return void
23
     */
24
    public function compile(Buffer $buffer)
25
    {
26
        /** @var Script\Annotation[] $annotations */
27
        $annotations = array();
28
        $nodes = $this->nodes;
29
        while (current($nodes) instanceof Script\Annotation) {
30
            $annotations[] = array_shift($nodes);
31
        }
32
33
        foreach ($annotations as $annotation) {
34
            $annotation->beforeScript($buffer);
35
        }
36
37
        if (count($this->nodes)) {
38
            $buffer->write('$z->cmd(');
39
            foreach ($nodes as $i => $node) {
40
                if ($i > 0) {
41
                    $buffer->raw(' . ');
42
                }
43
                $buffer->raw('$z->str(');
44
                $node->compile($buffer);
45
                $buffer->raw(')');
46
            }
47
            $buffer->raw(');')->eol();
48
        }
49
50
        foreach (array_reverse($annotations) as $annotation) {
51
            $annotation->afterScript($buffer);
52
        }
53
    }
54
}
55