Completed
Pull Request — master (#15)
by Emanuele
14:44
created

FeatureExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 4
c 3
b 1
f 0
lcom 1
cbo 3
dl 0
loc 44
ccs 0
cts 10
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getTokenParsers() 0 6 1
A getName() 0 4 1
A isGranted() 0 4 1
1
<?php
2
3
namespace Ae\FeatureBundle\Twig\Extension;
4
5
use Ae\FeatureBundle\Service\Feature;
6
use Ae\FeatureBundle\Twig\TokenParser\FeatureTokenParser;
7
use Twig_Extension;
8
9
/**
10
 * @author Carlo Forghieri <[email protected]>
11
 */
12
class FeatureExtension extends Twig_Extension
13
{
14
    /**
15
     * @var Feature
16
     */
17
    protected $service;
18
19
    /**
20
     * @param Feature $service
21
     */
22
    public function __construct(Feature $service)
23
    {
24
        $this->service = $service;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function getTokenParsers()
31
    {
32
        return [
33
            new FeatureTokenParser(),
34
        ];
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getName()
41
    {
42
        return 'feature';
43
    }
44
45
    /**
46
     * @param string $name
47
     * @param string $parent
48
     *
49
     * @return bool
50
     */
51
    public function isGranted($name, $parent)
52
    {
53
        return $this->service->isGranted($name, $parent);
54
    }
55
}
56