Passed
Pull Request — master (#300)
by Arnaud
14:15 queued 08:05
created

ParametersMapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A map() 0 10 2
1
<?php
2
3
namespace LAG\AdminBundle\Routing\Parameter;
4
5
use Symfony\Component\PropertyAccess\PropertyAccess;
6
7
class ParametersMapper
8
{
9
    public function map(object $data, array $routeParameters = []): array
10
    {
11
        $accessor = PropertyAccess::createPropertyAccessor();
12
        $mappedRouteParameters = [];
13
14
        foreach ($routeParameters as $parameter => $requirements) {
15
            $mappedRouteParameters[$parameter] = $accessor->getValue($data, (string)$parameter);
16
        }
17
18
        return $mappedRouteParameters;
19
    }
20
}
21