AnnotationsTokenParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 9
c 2
b 1
f 1
dl 0
loc 40
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTag() 0 3 1
A decideEndAnnotations() 0 3 1
A parse() 0 10 1
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
namespace Zicht\Bundle\FrameworkExtraBundle\Twig\Meta;
7
8
use Twig_Token;
9
10
/**
11
 * Class AnnotationsTokenParser
12
 *
13
 * @package Zicht\Bundle\FrameworkExtraBundle\Twig\Meta
14
 */
15
class AnnotationsTokenParser extends \Twig_TokenParser
16
{
17
    /**
18
     * Parses a token and returns a node.
19
     *
20
     * @param Twig_Token $token A Twig_Token instance
21
     *
22
     * @return AnnotationsNode A Twig_NodeInterface instance
23
     */
24
    public function parse(Twig_Token $token)
25
    {
26
        $stream = $this->parser->getStream();
27
28
        $stream->expect(Twig_Token::BLOCK_END_TYPE);
29
        $body = $this->parser->subparse(array($this, 'decideEndAnnotations'));
30
        $stream->expect('endannotations');
31
        $stream->expect(Twig_Token::BLOCK_END_TYPE);
32
33
        return new AnnotationsNode(array('body' => $body));
34
    }
35
36
    /**
37
     * Gets the tag name associated with this token parser.
38
     *
39
     * @return string The tag name
40
     */
41
    public function getTag()
42
    {
43
        return 'annotations';
44
    }
45
46
    /**
47
     * Decide end annotations
48
     *
49
     * @param string $token
50
     * @return mixed
51
     */
52
    public function decideEndAnnotations($token)
53
    {
54
        return $token->test('endannotations');
55
    }
56
}
57