ContainerTokenParser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A decideEnd() 0 4 1
A getTag() 0 4 1
A parse() 0 19 2
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Templates System.
5
 *
6
 * Copyright 2015 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Component\TemplatesSystem\Twig\TokenParser;
16
17
use SWP\Component\TemplatesSystem\Twig\Node\ContainerNode;
18
19
/**
20
 * @deprecated since 2.0, will be removed in 3.0
21
 * Parser for container/endcontainer blocks.
22
 */
23
class ContainerTokenParser extends \Twig\TokenParser\AbstractTokenParser
24
{
25
    /**
26
     * @param \Twig\Token $token
27
     *
28
     * @return bool
29
     */
30
    public function decideEnd(\Twig\Token $token)
31
    {
32
        return $token->test('endcontainer');
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getTag()
39
    {
40
        return 'container';
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function parse(\Twig\Token $token)
47
    {
48
        $lineno = $token->getLine();
49
        $stream = $this->parser->getStream();
50
51
        $name = $this->parser->getExpressionParser()->parseExpression();
52
53
        $parameters = null;
54
        if ($stream->nextIf(\Twig\Token::NAME_TYPE, 'with')) {
55
            $parameters = $this->parser->getExpressionParser()->parseExpression();
56
        }
57
58
        $stream->expect(\Twig\Token::BLOCK_END_TYPE);
59
        $body = $this->parser->subparse([$this, 'decideEnd'], true);
60
61
        $stream->expect(\Twig\Token::BLOCK_END_TYPE);
62
63
        return new ContainerNode($name, $parameters, $body, $lineno, $this->getTag());
0 ignored issues
show
Deprecated Code introduced by
The class SWP\Component\TemplatesS...Twig\Node\ContainerNode has been deprecated with message: since 2.0, will be removed in 3.0
Container twig node.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
64
    }
65
}
66