Completed
Push — master ( c114e4...0fa665 )
by Eric
9s
created

SecurityChecker   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A isGranted() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the Lug package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Lug\Bundle\ResourceBundle\Security;
13
14
use Lug\Bundle\ResourceBundle\Routing\ParameterResolverInterface;
15
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
16
17
/**
18
 * @author GeLo <[email protected]>
19
 */
20
class SecurityChecker implements SecurityCheckerInterface
21
{
22
    /**
23
     * @var AuthorizationCheckerInterface
24
     */
25
    private $authorizationChecker;
26
27
    /**
28
     * @var ParameterResolverInterface
29
     */
30
    private $parameterResolver;
31
32
    /**
33
     * @param AuthorizationCheckerInterface $authorizationChecker
34
     * @param ParameterResolverInterface    $parameterResolver
35
     */
36 4
    public function __construct(
37
        AuthorizationCheckerInterface $authorizationChecker,
38
        ParameterResolverInterface $parameterResolver
39
    ) {
40 4
        $this->authorizationChecker = $authorizationChecker;
41 4
        $this->parameterResolver = $parameterResolver;
42 4
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 2
    public function isGranted($action, $object)
48
    {
49 2
        if (!$this->parameterResolver->resolveVoter()) {
50 1
            return true;
51
        }
52
53 1
        return $this->authorizationChecker->isGranted('lug.'.$action, $object);
54
    }
55
}
56