SecurityExtension   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFunctions() 0 6 1
A getName() 0 4 1
1
<?php
2
3
namespace JDecool\Bundle\SecurityRoleCheckerBundle\Twig\Extension;
4
5
use JDecool\Bundle\SecurityRoleCheckerBundle\Security\RoleCheckerInterface;
6
7
class SecurityExtension extends \Twig_Extension
8
{
9
    /** @var RoleCheckerInterface */
10
    private $roleChecker;
11
12
    /**
13
     * Constructor
14
     *
15
     * @param RoleCheckerInterface $roleChecker
16
     */
17
    public function __construct(RoleCheckerInterface $roleChecker)
18
    {
19
        $this->roleChecker = $roleChecker;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function getFunctions()
26
    {
27
        return [
28
            new \Twig_SimpleFunction('has_role', [$this->roleChecker, 'hasRole']),
29
        ];
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function getName()
36
    {
37
        return 'security.role_checker';
38
    }
39
}
40