Completed
Push — master ( e3a66c...d34c1a )
by Christophe
06:31
created

TwigListener::getLexer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4286
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Chris\Bundle\FrontRenderBundle\Listener;
4
5
class TwigListener
6
{
7
    /**
8
     * @var \Twig_Environment $twig
9
     */
10
    protected $twig;
11
12
    /**
13
     * @param \Twig_Environment $twig
14
     */
15
    public function __construct(\Twig_Environment $twig)
16
    {
17
        $this->twig = $twig;
18
    }
19
20
    /**
21
     * Update twig tags
22
     */
23
    public function updateTagTwig()
24
    {
25
        $lexer = $this->getLexer();
26
        $this->twig->setLexer($lexer);
27
    }
28
29
    public function getLexer()
30
    {
31
        $lexer = new \Twig_Lexer($this->twig, [
32
            'tag_comment'  => ['{*', '*}'],
33
            'tag_block'    => ['{@', '@}'],
34
            'tag_variable' => ['{$', '$}'],
35
        ]);
36
37
        return $lexer;
38
    }
39
}
40