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

TwigListener   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 3
c 4
b 0
f 1
lcom 1
cbo 2
dl 0
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A updateTagTwig() 0 5 1
A getLexer() 0 10 1
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