AbstractTokenParser::parseBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace MewesK\TwigExcelBundle\Twig\TokenParser;
4
5
use Twig_Node;
6
use Twig_Node_Expression_Array;
7
use Twig_Token;
8
use Twig_TokenParser;
9
10
/**
11
 * Class AbstractTokenParser
12
 *
13
 * @package MewesK\TwigExcelBundle\Twig\TokenParser
14
 */
15
abstract class AbstractTokenParser extends Twig_TokenParser
16
{
17
    /**
18
     * @return Twig_Node
19
     * @throws \Twig_Error_Syntax
20
     */
21
    protected function parseBody()
22
    {
23
        $body = $this->parser->subparse(function (Twig_Token $token) {
24
            return $token->test('end' . $this->getTag());
25
        },
26
            true);
27
        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
28
29
        return $body;
30
    }
31
32
    /**
33
     * @param Twig_Token $token
34
     * @return mixed|\Twig_Node_Expression_Array|\Twig_Node_Expression_Conditional|\Twig_Node_Expression_GetAttr
35
     */
36
    protected function parseProperties(Twig_Token $token)
37
    {
38
        $properties = new Twig_Node_Expression_Array([], $token->getLine());
39
        if (!$this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) {
40
            $properties = $this->parser->getExpressionParser()->parseExpression();
41
        }
42
43
        return $properties;
44
    }
45
}
46