MiscExtension   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 5
eloc 11
dl 0
loc 29
ccs 6
cts 12
cp 0.5
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A serviceExists() 0 3 1
A getFunctions() 0 5 1
A getParameter() 0 6 2
A __construct() 0 3 1
1
<?php
2
3
namespace Fi\CoreBundle\Twig\Extension;
4
5
use Symfony\Component\DependencyInjection\ContainerInterface;
6
use Twig_Extension;
7
use Twig_SimpleFunction;
8
9
class MiscExtension extends Twig_Extension
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Extension has been deprecated: since Twig 2.7, use "Twig\Extension\AbstractExtension" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

9
class MiscExtension extends /** @scrutinizer ignore-deprecated */ Twig_Extension
Loading history...
10
{
11
    protected $container;
12
13 35
    public function __construct(ContainerInterface $container)
14
    {
15 35
        $this->container = $container;
16 35
    }
17
18
    public function getFunctions()
19
    {
20
        return array(
21
            new Twig_SimpleFunction('serviceExists', array($this, 'serviceExists')),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated: since Twig 2.7, use "Twig\TwigFunction" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

21
            /** @scrutinizer ignore-deprecated */ new Twig_SimpleFunction('serviceExists', array($this, 'serviceExists')),
Loading history...
22
            new Twig_SimpleFunction('getParameter', array($this, 'getParameter')),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated: since Twig 2.7, use "Twig\TwigFunction" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

22
            /** @scrutinizer ignore-deprecated */ new Twig_SimpleFunction('getParameter', array($this, 'getParameter')),
Loading history...
23
        );
24
    }
25
26 13
    public function getParameter($parameter)
27
    {
28 13
        if ($this->container->hasParameter($parameter)) {
29 13
            return $this->container->getParameter($parameter);
30
        } else {
31
            return '';
32
        }
33
    }
34
35
    public function serviceExists($service)
36
    {
37
        return $this->container->has($service);
38
    }
39
}
40