Test Failed
Pull Request — master (#19)
by Pavel
10:42
created

CrudsParamConverter::getRouter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Listener;
4
5
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
6
7
final class CrudsParamConverter
8
{
9
    use CrudsRequestCheckerTrait;
10
11
    public function onCrudRequest(GetResponseEvent $event)
12
    {
13
        if (!$this->checkRequest($event)) {
14
            return;
15
        }
16
17
        $options = $this->getNormalizedCrudApiOptions($event);
18
        if (!$options['enabled']) {
19
            return;
20 26
        }
21
22 26
        $request = $event->getRequest();
23 26
        foreach ((array)$options['arguments'] as $param) {
24
            $value = $request->get($param);
25 26
            if (null !== $value) {
26
                $request->attributes->set($param, $value);
27 26
            }
28
        }
29
    }
30
}
31