FlashBagParamConverter::supports()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

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