SecurityContextParamConverter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Zenstruck\ControllerUtil\ParamConverter;
4
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\Security\Core\SecurityContextInterface;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
class SecurityContextParamConverter implements ParamConverter
12
{
13
    private $securityContext;
14
15 2
    public function __construct(SecurityContextInterface $securityContext)
16
    {
17 2
        $this->securityContext = $securityContext;
18 2
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 1
    public function getObject(Request $request)
24
    {
25 1
        return $this->securityContext;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 1
    public function supports($class)
32
    {
33 1
        return is_subclass_of($class, 'Symfony\\Component\\Security\\Core\\SecurityContextInterface') ||
34 1
            $class === 'Symfony\\Component\\Security\\Core\\SecurityContextInterface';
35
    }
36
}
37