XlsRowNode   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A compile() 0 12 1
A getAllowedParents() 0 6 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 XlsRowNode
11
 *
12
 * @package MewesK\TwigExcelBundle\Twig\Node
13
 */
14
class XlsRowNode extends Twig_Node implements SyntaxAwareNodeInterface
15
{
16
    /**
17
     * @param Twig_Node_Expression $index
18
     * @param Twig_Node $body
19
     * @param int $line
20
     * @param string $tag
21
     */
22
    public function __construct(Twig_Node_Expression $index, Twig_Node $body, $line = 0, $tag = 'xlsrow')
23
    {
24
        parent::__construct(['index' => $index, 'body' => $body], [], $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('$context[\'phpExcel\']->setRowIndex(')
34
            ->subcompile($this->getNode('index'))
35
            ->raw(');' . PHP_EOL)
36
            ->write('$context[\'phpExcel\']->startRow($context[\'phpExcel\']->getRowIndex());' . PHP_EOL)
37
            ->write('$context[\'phpExcel\']->setRowIndex(0);' . PHP_EOL)
38
            ->subcompile($this->getNode('body'))
39
            ->addDebugInfo($this)
40
            ->write('$context[\'phpExcel\']->endRow();' . PHP_EOL);
41
    }
42
43
    /**
44
     * @return string[]
45
     */
46
    public function getAllowedParents()
47
    {
48
        return [
49
            'MewesK\TwigExcelBundle\Twig\Node\XlsSheetNode'
50
        ];
51
    }
52
53
    /**
54
     * @return bool
55
     */
56
    public function canContainText()
57
    {
58
        return false;
59
    }
60
}
61