XlsSheetTokenParser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 16 3
A getTag() 0 4 1
1
<?php
2
3
namespace MewesK\TwigExcelBundle\Twig\TokenParser;
4
5
use MewesK\TwigExcelBundle\Twig\Node\XlsSheetNode;
6
use Twig_Node_Expression_Constant;
7
use Twig_Token;
8
9
/**
10
 * Class XlsSheetTokenParser
11
 *
12
 * @package MewesK\TwigExcelBundle\Twig\TokenParser
13
 */
14
class XlsSheetTokenParser extends AbstractTokenParser
15
{
16
    /**
17
     * @param Twig_Token $token
18
     *
19
     * @return XlsSheetNode
20
     * @throws \Twig_Error_Syntax
21
     */
22
    public function parse(Twig_Token $token)
23
    {
24
        // parse attributes
25
        $title = new Twig_Node_Expression_Constant(null, $token->getLine());
26
        if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE) && !$this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) {
27
            $title = $this->parser->getExpressionParser()->parseExpression();
28
        }
29
        $properties = $this->parseProperties($token);
30
        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
31
32
        // parse body
33
        $body = $this->parseBody();
34
35
        // return node
36
        return new XlsSheetNode($title, $properties, $body, $token->getLine(), $this->getTag());
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    public function getTag()
43
    {
44
        return 'xlssheet';
45
    }
46
}
47