UriVariablesExtractor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 17
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A extractVariables() 0 15 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LAG\AdminBundle\Request\Uri;
6
7
use LAG\AdminBundle\Metadata\OperationInterface;
8
use Symfony\Component\HttpFoundation\Request;
9
10
class UriVariablesExtractor implements UriVariablesExtractorInterface
11
{
12
    public function extractVariables(OperationInterface $operation, Request $request): array
13
    {
14
        $uriVariables = [];
15
16
        foreach ($operation->getIdentifiers() as $identifier) {
17
            if ($request->attributes->has($identifier)) {
18
                $uriVariables[$identifier] = $request->attributes->get($identifier);
19
            }
20
21
            if ($request->query->has($identifier)) {
22
                $uriVariables[$identifier] = $request->query->get($identifier);
23
            }
24
        }
25
26
        return $uriVariables;
27
    }
28
}
29