@@ -39,27 +39,34 @@ public function toArray(array $additionalData): array
39
39
{
40
40
$ parsedAdditionalData = [];
41
41
42
- $ convertToProviders = function ($ additionalDatum ) use (&$ convertToProviders ) {
43
- $ processedData = [];
42
+ foreach ($ additionalData as $ key => $ additionalDataItem ) {
43
+ $ additionalDataItem = $ this ->argumentInterpreter ->evaluate ($ additionalDataItem );
44
+ $ parsedAdditionalData [$ key ] = $ this ->evaluateProviders ($ additionalDataItem );
45
+ }
44
46
45
- foreach ( $ additionalDatum as $ key => $ value ) {
46
- $ processedData [ $ key ] = $ value ;
47
+ return $ parsedAdditionalData ;
48
+ }
47
49
48
- if (is_array ($ value )) {
49
- $ processedData [$ key ] = $ convertToProviders ($ additionalDatum [$ key ]);
50
- } elseif (is_object ($ value ) && $ value instanceof ProviderInterface) {
51
- $ processedData [$ key ] = $ value ->getData ($ key )[$ key ];
52
- }
53
- }
50
+ /**
51
+ * Evaluate ProviderInterface objects
52
+ *
53
+ * @param array $additionalDataItem
54
+ * @return array
55
+ */
56
+ private function evaluateProviders (array $ additionalDataItem ): array
57
+ {
58
+ $ processedData = [];
54
59
55
- return $ processedData ;
56
- } ;
60
+ foreach ( $ additionalDataItem as $ key => $ value ) {
61
+ $ processedData [ $ key ] = $ value ;
57
62
58
- foreach ($ additionalData as $ key => $ additionalDatum ) {
59
- $ additionalDatum = $ this ->argumentInterpreter ->evaluate ($ additionalDatum );
60
- $ parsedAdditionalData [$ key ] = $ convertToProviders ($ additionalDatum );
63
+ if (is_array ($ value )) {
64
+ $ processedData [$ key ] = $ this ->evaluateProviders ($ additionalDataItem [$ key ]);
65
+ } elseif (is_object ($ value ) && $ value instanceof ProviderInterface) {
66
+ $ processedData [$ key ] = $ value ->getData ($ key )[$ key ];
67
+ }
61
68
}
62
69
63
- return $ parsedAdditionalData ;
70
+ return $ processedData ;
64
71
}
65
72
}
0 commit comments