ProfilerExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 54
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getTemplateDirectory() 0 6 1
A getFilters() 0 8 1
A getName() 0 4 1
1
<?php
2
/*
3
 * This file is part of the PommProject/PommBundle package.
4
 *
5
 * (c) 2014 Grégoire HUBERT <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PommProject\PommBundle\Twig\Extension;
11
12
/**
13
 * ProfilerExtension
14
 *
15
 * Twig extension for Pomm2 profiler.
16
 *
17
 * @package PommBundle
18
 * @copyright 2014 Grégoire HUBERT
19
 * @author Nicolas JOSEPH
20
 * @license X11 {@link http://opensource.org/licenses/mit-license.php}
21
 * @see \Twig_Extension
22
 */
23
class ProfilerExtension extends \Twig_Extension
24
{
25
    /**
26
     * __construct
27
     *
28
     * Extension constructor.
29
     *
30
     * @access public
31
     * @param  \Twig_Loader_Filesystem $loader
32
     */
33
    public function __construct(\Twig_Loader_Filesystem $loader)
34
    {
35
        $loader->addPath($this->getTemplateDirectory(), 'Pomm');
36
    }
37
38
    /**
39
     * getTemplateDirectory
40
     *
41
     * Return the current package template directory.
42
     *
43
     * @access private
44
     * @return string
45
     */
46
    private function getTemplateDirectory()
47
    {
48
        $r = new \ReflectionClass('PommProject\\SymfonyBridge\\DatabaseDataCollector');
49
50
        return dirname(dirname(dirname($r->getFileName()))).'/views';
51
    }
52
53
    /**
54
     * getFilters
55
     *
56
     * @see \Twig_Extension
57
     */
58
    public function getFilters()
59
    {
60
        return [
61
            new \Twig_SimpleFilter('sql_format', function ($sql) {
62
                return \SqlFormatter::format($sql);
63
            }),
64
        ];
65
    }
66
67
    /**
68
     * getName
69
     *
70
     * @see \Twig_Extension
71
     */
72
    public function getName()
73
    {
74
        return 'pomm';
75
    }
76
}
77