Conditions | 2 |
Paths | 2 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
34 | public function serializeField(string $path, Request $request, $object, SerializerInterface $serializer = null) |
||
35 | { |
||
36 | $this->serializerOrException($serializer); |
||
37 | |||
38 | $collection = []; |
||
39 | foreach ($this->accessor->getValue($object) as $i => $childObject) { |
||
40 | $subPath = $path.'.['.$i.']'; |
||
41 | $collection[$i] = $serializer->serialize($request, $childObject, $subPath); |
||
|
|||
42 | } |
||
43 | |||
44 | return $collection; |
||
45 | } |
||
46 | |||
59 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: