ExtendsAdmingeneratedTokenParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 8
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 17 2
A getTag() 0 4 1
1
<?php
2
3
namespace Admingenerator\GeneratorBundle\Twig\TokenParser;
4
5
class ExtendsAdmingeneratedTokenParser extends \Twig_TokenParser
0 ignored issues
show
Deprecated Code introduced by
The class Twig_TokenParser has been deprecated with message: since Twig 2.7, use "Twig\TokenParser\AbstractTokenParser" instead

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...
6
{
7
8
    /**
9
     * Parses a token and returns a node.
10
     *
11
     * @param \Twig_Token $token A \Twig_Token instance
12
     *
13
     * @return \Twig_NodeInterface A \Twig_NodeInterface instance
14
     */
15
    public function parse(\Twig_Token $token)
16
    {
17
        if (null !== $this->parser->getParent()) {
18
            throw new \Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine());
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Error_Syntax has been deprecated with message: since Twig 2.7, use "Twig\Error\SyntaxError" instead

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...
19
        }
20
21
        list($bundle, $folder, $file) = explode(':', $this->parser->getCurrentToken()->getValue());
22
23
        $path = "Admingenerated/$bundle/Resources/views/$folder/$file";
24
25
        $this->parser->getExpressionParser()->parseExpression();
26
27
        $this->parser->setParent(new \Twig_Node_Expression_Constant($path,$token->getLine()));
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Node_Expression_Constant has been deprecated with message: since Twig 2.7, use "Twig\Node\Expression\ConstantExpression" instead

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...
28
        $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
29
30
        return null;
31
    }
32
33
    /**
34
     * Gets the tag name associated with this token parser.
35
     *
36
     * @return string The tag name
37
     */
38
    public function getTag()
39
    {
40
        return 'extends_admingenerated';
41
    }
42
}
43