Completed
Push — 4.1 ( c9c1fa...5cccd6 )
by Andrea
13:13
created

MiscExtension::getParameter()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Fi\CoreBundle\Twig\Extension;
4
5
use Symfony\Component\DependencyInjection\ContainerInterface;
6
7
class MiscExtension extends \Twig_Extension
8
{
9
    protected $container;
10
11 10
    public function __construct(ContainerInterface $container)
12
    {
13 10
        $this->container = $container;
14 10
    }
15
16
    public function getFunctions()
17
    {
18
        return array(
19
            new \Twig_SimpleFunction('serviceExists', array($this, 'serviceExists')),
20
            new \Twig_SimpleFunction('getParameter', array($this, 'getParameter')),
21
        );
22
    }
23
24
    public function getParameter($parameter)
25
    {
26
        if ($this->container->hasParameter($parameter)) {
27
            return $this->container->getParameter($parameter);
28
        } else {
29
            return '';
30
        }
31
    }
32
33
    public function serviceExists($service)
34
    {
35
        return $this->container->has($service);
36
    }
37
}
38