XlsDrawingNode   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 51
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A compile() 0 13 1
A getAllowedParents() 0 9 1
A canContainText() 0 4 1
1
<?php
2
3
namespace MewesK\TwigExcelBundle\Twig\Node;
4
5
use Twig_Compiler;
6
use Twig_Node;
7
use Twig_Node_Expression;
8
9
/**
10
 * Class XlsDrawingNode
11
 *
12
 * @package MewesK\TwigExcelBundle\Twig\Node
13
 */
14
class XlsDrawingNode extends Twig_Node implements SyntaxAwareNodeInterface
15
{
16
    /**
17
     * @param Twig_Node_Expression $path
18
     * @param Twig_Node_Expression $properties
19
     * @param int $line
20
     * @param string $tag
21
     */
22
    public function __construct(Twig_Node_Expression $path, Twig_Node_Expression $properties, $line = 0, $tag = 'xlsdrawing')
23
    {
24
        parent::__construct(['path' => $path, 'properties' => $properties], [], $line, $tag);
25
    }
26
27
    /**
28
     * @param Twig_Compiler $compiler
29
     */
30
    public function compile(Twig_Compiler $compiler)
31
    {
32
        $compiler->addDebugInfo($this)
33
            ->write('$drawingPath = ')
34
            ->subcompile($this->getNode('path'))
35
            ->raw(';' . PHP_EOL)
36
            ->write('$drawingProperties = ')
37
            ->subcompile($this->getNode('properties'))
38
            ->raw(';' . PHP_EOL)
39
            ->write('$context[\'phpExcel\']->startDrawing($drawingPath, $drawingProperties);' . PHP_EOL)
40
            ->write('unset($drawingPath, $drawingProperties);' . PHP_EOL)
41
            ->write('$context[\'phpExcel\']->endDrawing();' . PHP_EOL);
42
    }
43
44
    /**
45
     * @return string[]
46
     */
47
    public function getAllowedParents()
48
    {
49
        return [
50
            'MewesK\TwigExcelBundle\Twig\Node\XlsSheetNode',
51
            'MewesK\TwigExcelBundle\Twig\Node\XlsLeftNode',
52
            'MewesK\TwigExcelBundle\Twig\Node\XlsCenterNode',
53
            'MewesK\TwigExcelBundle\Twig\Node\XlsRightNode'
54
        ];
55
    }
56
57
    /**
58
     * @return bool
59
     */
60
    public function canContainText()
61
    {
62
        return false;
63
    }
64
}
65