Completed
Branch master (c0d8ef)
by Yaroslav
06:36
created

SymfonyAccessControlResolver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 1
crap 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\TestResolver;
12
13
use Symfony\Component\HttpFoundation\RequestStack;
14
use Yarhon\RouteGuardBundle\Security\Test\TestInterface;
15
use Yarhon\RouteGuardBundle\Security\Test\SymfonySecurityTest;
16
use Yarhon\RouteGuardBundle\Routing\RouteContextInterface;
17
use Yarhon\RouteGuardBundle\Security\TestProvider\SymfonyAccessControlProvider;
18
19
/**
20
 * @author Yaroslav Honcharuk <[email protected]>
21
 */
22
class SymfonyAccessControlResolver implements TestResolverInterface
23
{
24
    /**
25
     * @var RequestStack
26
     */
27
    private $requestStack;
28
29
    /**
30
     * @param RequestStack $requestStack
31
     */
32 2
    public function __construct(RequestStack $requestStack)
33
    {
34 2
        $this->requestStack = $requestStack;
35 2
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function supports(TestInterface $test)
41
    {
42 1
        return SymfonyAccessControlProvider::class === $test->getProviderClass();
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 1
    public function resolve(TestInterface $test, RouteContextInterface $routeContext)
49
    {
50
        /* @var SymfonySecurityTest $test */
51
52 1
        return [$test->getAttributes(), $this->requestStack->getCurrentRequest()];
53
    }
54
}
55