SvgTwigExtension::getFunctions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Victoire\Bundle\MediaBundle\Twig;
4
5
/**
6
 * MenuTwigExtension.
7
 */
8
class SvgTwigExtension extends \Twig_Extension
9
{
10
    protected $kernelRootDir;
11
12
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$kernelRootDir" missing
Loading history...
13
     * SvgTwigExtension constructor.
14
     *
15
     * @param $kernelRootDir
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
16
     */
17
    public function __construct($kernelRootDir)
18
    {
19
        $this->kernelRootDir = $kernelRootDir;
20
    }
21
22
    public function getFunctions()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
23
    {
24
        return [
25
            new \Twig_SimpleFunction('include_svg', [$this, 'includeSvg'], ['is_safe' => ['html']]),
26
        ];
27
    }
28
29
    public function includeSvg($url)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
30
    {
31
        return file_get_contents($this->kernelRootDir.'/../web'.$url);
32
    }
33
34
    public function getName()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
35
    {
36
        return 'victoire_media_svg_extension';
37
    }
38
}
39