| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 2 | public function serializeField(string $path, Request $request, $object, SerializerInterface $serializer = null) |
|
| 35 | { |
||
| 36 | 2 | $this->serializerOrException($serializer); |
|
| 37 | |||
| 38 | 1 | $collection = []; |
|
| 39 | 1 | foreach ($this->accessor->getValue($object) as $i => $childObject) { |
|
| 40 | 1 | $subPath = $path.'.['.$i.']'; |
|
| 41 | 1 | $collection[$i] = $serializer->serialize($request, $childObject, $subPath); |
|
|
|
|||
| 42 | } |
||
| 43 | |||
| 44 | 1 | 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: