LoadedByPuliTokenParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 28
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 6 1
A getTag() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the puli/twig-puli-extension package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\TwigExtension\TokenParser;
13
14
use Puli\TwigExtension\Node\LoadedByPuliNode;
15
use Twig_Error_Syntax;
16
use Twig_NodeInterface;
17
use Twig_Token;
18
use Twig_TokenParser;
19
20
/**
21
 * Turns the "{% loaded_by_puli %}" token into an instance of
22
 * {@link LoadedByPuliNode}.
23
 *
24
 * @since  1.0
25
 *
26
 * @author Bernhard Schussek <[email protected]>
27
 */
28
class LoadedByPuliTokenParser extends Twig_TokenParser
29
{
30
    /**
31
     * Parses a token and returns a node.
32
     *
33
     * @param Twig_Token $token A Twig_Token instance
34
     *
35
     * @return Twig_NodeInterface A Twig_NodeInterface instance
36
     *
37
     * @throws Twig_Error_Syntax
38
     */
39 19
    public function parse(Twig_Token $token)
40
    {
41 19
        $this->parser->getStream()->next();
42
43 19
        return new LoadedByPuliNode();
44
    }
45
46
    /**
47
     * Gets the tag name associated with this token parser.
48
     *
49
     * @return string The tag name
50
     */
51 23
    public function getTag()
52
    {
53 23
        return 'loaded_by_puli';
54
    }
55
}
56