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

ParametersMapper::map()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 10
rs 10
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