CrudsParamConverter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 24
ccs 10
cts 12
cp 0.8333
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B onCrudRequest() 0 19 5
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