Completed
Push — master ( 42428f...823cf3 )
by Leny
13:56 queued 06:50
created

SvgTwigExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFunctions() 0 6 1
A includeSvg() 0 4 1
A getName() 0 4 1
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
    /**
13
     * SvgTwigExtension constructor.
14
     *
15
     * @param $kernelRootDir
16
     */
17
    public function __construct($kernelRootDir)
18
    {
19
        $this->kernelRootDir = $kernelRootDir;
20
    }
21
22
    public function getFunctions()
23
    {
24
        return [
25
            new \Twig_SimpleFunction('include_svg', [$this, 'includeSvg'], ['is_safe' => ['html']]),
26
        ];
27
    }
28
29
    public function includeSvg($url)
30
    {
31
        return file_get_contents($this->kernelRootDir.'/../web'.$url);
32
    }
33
34
    public function getName()
35
    {
36
        return 'victoire_media_svg_extension';
37
    }
38
}
39