RequestValueResolver::resolve()   A
last analyzed

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 2
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\Controller\ArgumentResolver;
12
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
15
16
/**
17
 * Returns the same instance as the request object passed along.
18
 *
19
 * @author Yaroslav Honcharuk <[email protected]>
20
 * @author Iltar van der Berg <[email protected]>
21
 */
22
final class RequestValueResolver implements ArgumentValueResolverInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27 6
    public function supports(ArgumentResolverContextInterface $context, ArgumentMetadata $argument)
28
    {
29 6
        return Request::class === $argument->getType() || is_subclass_of($argument->getType(), Request::class);
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 1
    public function resolve(ArgumentResolverContextInterface $context, ArgumentMetadata $argument)
36
    {
37 1
        return $context->getRequest();
38
    }
39
}
40