| Total Complexity | 6 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | trait FieldsToAttributesTrait |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * Recursively replaces the key "_id" (the raw id in GraphQL) by "id" (the name of the property expected by the Serializer) and flatten edge and node structures (pagination). |
||
| 27 | */ |
||
| 28 | private function fieldsToAttributes(ResolveInfo $info): array |
||
| 29 | { |
||
| 30 | $fields = $info->getFieldSelection(PHP_INT_MAX); |
||
| 31 | if (isset($fields['edges']['node'])) { |
||
| 32 | $fields = $fields['edges']['node']; |
||
| 33 | } |
||
| 34 | |||
| 35 | return $this->replaceIdKeys($fields); |
||
| 36 | } |
||
| 37 | |||
| 38 | private function replaceIdKeys(array $fields): array |
||
| 50 | } |
||
| 51 | } |
||
| 52 |