SymfonySecurityAuthorizationChecker   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 38
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isGranted() 0 5 1
A supports() 0 3 1
1
<?php
2
3
/*
4
 *
5
 * (c) Yaroslav Honcharuk <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Yarhon\RouteGuardBundle\Security\AuthorizationChecker;
12
13
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface as BaseAuthorizationCheckerInterface;
14
use Yarhon\RouteGuardBundle\Routing\RouteContextInterface;
15
use Yarhon\RouteGuardBundle\Security\Test\TestInterface;
16
use Yarhon\RouteGuardBundle\Security\Test\AbstractSymfonySecurityTest;
17
use Yarhon\RouteGuardBundle\Security\TestResolver\SymfonySecurityResolverInterface;
18
19
/**
20
 * @author Yaroslav Honcharuk <[email protected]>
21
 */
22
class SymfonySecurityAuthorizationChecker implements AuthorizationCheckerInterface
23
{
24
    /**
25
     * @var BaseAuthorizationCheckerInterface
26
     */
27
    private $authorizationChecker;
28
29
    /**
30
     * @var SymfonySecurityResolverInterface
31
     */
32
    private $testResolver;
33
34
    /**
35
     * @param BaseAuthorizationCheckerInterface $authorizationChecker
36
     * @param SymfonySecurityResolverInterface  $testResolver
37
     */
38 22
    public function __construct(BaseAuthorizationCheckerInterface $authorizationChecker, SymfonySecurityResolverInterface $testResolver)
39
    {
40 22
        $this->authorizationChecker = $authorizationChecker;
41 22
        $this->testResolver = $testResolver;
42 22
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 15
    public function isGranted(TestInterface $test, RouteContextInterface $routeContext)
48
    {
49 15
        $arguments = $this->testResolver->resolve($test, $routeContext);
50
51 15
        return $this->authorizationChecker->isGranted(...$arguments);
0 ignored issues
show
Bug introduced by
$arguments is expanded, but the parameter $attributes of Symfony\Component\Securi...rInterface::isGranted() does not expect variable arguments. ( Ignorable by Annotation )

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

51
        return $this->authorizationChecker->isGranted(/** @scrutinizer ignore-type */ ...$arguments);
Loading history...
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 15
    public function supports(TestInterface $test)
58
    {
59 15
        return $test instanceof AbstractSymfonySecurityTest;
60
    }
61
}
62