| Conditions | 2 |
| Paths | 2 |
| Total Lines | 11 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 27 | public function enrich(string $json): string |
||
| 28 | { |
||
| 29 | $questionAsArray = json_decode($json, true); |
||
| 30 | |||
| 31 | $questionAsArray['id'] = $this->uuidFactory->uuid4()->toString(); |
||
| 32 | |||
| 33 | for ($index = 0; $index < count($questionAsArray['answers']); $index++) { |
||
|
|
|||
| 34 | $questionAsArray['answers'][$index]['id'] = $this->uuidFactory->uuid4()->toString(); |
||
| 35 | } |
||
| 36 | |||
| 37 | return json_encode($questionAsArray); |
||
| 38 | } |
||
| 40 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: