Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
25 | 1 | public function normalize($object, $format = null, array $context = []) |
|
26 | { |
||
27 | 1 | $data = []; |
|
28 | 1 | $reflectionClass = new \ReflectionClass($object); |
|
29 | /** @var \ReflectionProperty[] $properties */ |
||
30 | 1 | $properties = array_filter($reflectionClass->getProperties(), function (\ReflectionProperty $property) { |
|
31 | 1 | return 'requests' !== $property->getName(); |
|
32 | 1 | }); |
|
33 | |||
34 | 1 | foreach ($properties as $property) { |
|
35 | 1 | $method = $reflectionClass->getMethod('get'.Inflector::classify($property->getName())); |
|
36 | 1 | if ('collection' === $property->getName()) { |
|
37 | 1 | $data[$property->getName().'Id'] = $method->invoke($object)->getId(); |
|
38 | 1 | } else { |
|
39 | 1 | $data[$property->getName()] = $method->invoke($object); |
|
40 | } |
||
41 | 1 | } |
|
42 | |||
43 | 1 | return $data; |
|
44 | } |
||
45 | |||
54 |