CrudsParamConverter::onCrudRequest()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5.1158

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 19
ccs 10
cts 12
cp 0.8333
rs 8.8571
c 1
b 0
f 0
cc 5
eloc 11
nc 5
nop 1
crap 5.1158
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 26
    public function onCrudRequest(GetResponseEvent $event)
12
    {
13 26
        if (!$this->checkRequest($event)) {
14
            return;
15
        }
16
17 26
        $options = $this->getNormalizedCrudApiOptions($event);
18 26
        if (!$options['enabled']) {
19
            return;
20
        }
21
22 26
        $request = $event->getRequest();
23 26
        foreach ((array)$options['arguments'] as $param) {
24 26
            $value = $request->get($param);
25 26
            if (null !== $value) {
26 26
                $request->attributes->set($param, $value);
27
            }
28
        }
29 26
    }
30
}
31