@@ -136,77 +136,102 @@ public function getUnprocessedKeys(): array
136
136
protected function populateResult (Response $ response ): void
137
137
{
138
138
$ data = $ response ->toArray ();
139
- $ fn = [];
140
- $ fn ['list-ItemList ' ] = static function (array $ json ) use (&$ fn ): array {
141
- $ items = [];
142
- foreach ($ json as $ item ) {
143
- $ a = empty ($ item ) ? [] : $ fn ['map-AttributeMap ' ]($ item );
144
- if (null !== $ a ) {
145
- $ items [] = $ a ;
146
- }
147
- }
148
139
149
- return $ items ;
150
- };
140
+ $ this ->Responses = empty ($ data ['Responses ' ]) ? [] : $ this ->populateResultBatchGetResponseMap ($ data ['Responses ' ]);
141
+ $ this ->UnprocessedKeys = empty ($ data ['UnprocessedKeys ' ]) ? [] : $ this ->populateResultBatchGetRequestMap ($ data ['UnprocessedKeys ' ]);
142
+ $ this ->ConsumedCapacity = empty ($ data ['ConsumedCapacity ' ]) ? [] : $ this ->populateResultConsumedCapacityMultiple ($ data ['ConsumedCapacity ' ]);
143
+ }
151
144
152
- /** @return array<string, \AsyncAws\DynamoDb\ValueObject\AttributeValue> */
153
- $ fn ['map-AttributeMap ' ] = static function (array $ json ): array {
154
- $ items = [];
155
- foreach ($ json as $ name => $ value ) {
156
- $ items [(string ) $ name ] = AttributeValue::create ($ value );
157
- }
145
+ /**
146
+ * @return array<string, AttributeValue>
147
+ */
148
+ private function populateResultAttributeMap (array $ json ): array
149
+ {
150
+ $ items = [];
151
+ foreach ($ json as $ name => $ value ) {
152
+ $ items [(string ) $ name ] = AttributeValue::create ($ value );
153
+ }
158
154
159
- return $ items ;
160
- };
155
+ return $ items ;
156
+ }
161
157
162
- /** @return array<string, \AsyncAws\DynamoDb\ValueObject\KeysAndAttributes> */
163
- $ fn ['map-BatchGetRequestMap ' ] = static function (array $ json ): array {
164
- $ items = [];
165
- foreach ($ json as $ name => $ value ) {
166
- $ items [(string ) $ name ] = KeysAndAttributes::create ($ value );
167
- }
158
+ /**
159
+ * @return array<string, KeysAndAttributes>
160
+ */
161
+ private function populateResultBatchGetRequestMap (array $ json ): array
162
+ {
163
+ $ items = [];
164
+ foreach ($ json as $ name => $ value ) {
165
+ $ items [(string ) $ name ] = KeysAndAttributes::create ($ value );
166
+ }
168
167
169
- return $ items ;
170
- };
171
- $ fn ['list-ConsumedCapacityMultiple ' ] = static function (array $ json ) use (&$ fn ): array {
172
- $ items = [];
173
- foreach ($ json as $ item ) {
174
- $ items [] = new ConsumedCapacity ([
175
- 'TableName ' => isset ($ item ['TableName ' ]) ? (string ) $ item ['TableName ' ] : null ,
176
- 'CapacityUnits ' => isset ($ item ['CapacityUnits ' ]) ? (float ) $ item ['CapacityUnits ' ] : null ,
177
- 'ReadCapacityUnits ' => isset ($ item ['ReadCapacityUnits ' ]) ? (float ) $ item ['ReadCapacityUnits ' ] : null ,
178
- 'WriteCapacityUnits ' => isset ($ item ['WriteCapacityUnits ' ]) ? (float ) $ item ['WriteCapacityUnits ' ] : null ,
179
- 'Table ' => empty ($ item ['Table ' ]) ? null : new Capacity ([
180
- 'ReadCapacityUnits ' => isset ($ item ['Table ' ]['ReadCapacityUnits ' ]) ? (float ) $ item ['Table ' ]['ReadCapacityUnits ' ] : null ,
181
- 'WriteCapacityUnits ' => isset ($ item ['Table ' ]['WriteCapacityUnits ' ]) ? (float ) $ item ['Table ' ]['WriteCapacityUnits ' ] : null ,
182
- 'CapacityUnits ' => isset ($ item ['Table ' ]['CapacityUnits ' ]) ? (float ) $ item ['Table ' ]['CapacityUnits ' ] : null ,
183
- ]),
184
- 'LocalSecondaryIndexes ' => empty ($ item ['LocalSecondaryIndexes ' ]) ? [] : $ fn ['map-SecondaryIndexesCapacityMap ' ]($ item ['LocalSecondaryIndexes ' ]),
185
- 'GlobalSecondaryIndexes ' => empty ($ item ['GlobalSecondaryIndexes ' ]) ? [] : $ fn ['map-SecondaryIndexesCapacityMap ' ]($ item ['GlobalSecondaryIndexes ' ]),
186
- ]);
187
- }
168
+ return $ items ;
169
+ }
188
170
189
- return $ items ;
190
- };
171
+ /**
172
+ * @return array<string, array>
173
+ */
174
+ private function populateResultBatchGetResponseMap (array $ json ): array
175
+ {
176
+ $ items = [];
177
+ foreach ($ json as $ name => $ value ) {
178
+ $ items [(string ) $ name ] = $ this ->populateResultItemList ($ value );
179
+ }
191
180
192
- /** @return array<string, \AsyncAws\DynamoDb\ValueObject\Capacity> */
193
- $ fn ['map-SecondaryIndexesCapacityMap ' ] = static function (array $ json ): array {
194
- $ items = [];
195
- foreach ($ json as $ name => $ value ) {
196
- $ items [(string ) $ name ] = Capacity::create ($ value );
197
- }
181
+ return $ items ;
182
+ }
183
+
184
+ /**
185
+ * @return ConsumedCapacity[]
186
+ */
187
+ private function populateResultConsumedCapacityMultiple (array $ json ): array
188
+ {
189
+ $ items = [];
190
+ foreach ($ json as $ item ) {
191
+ $ items [] = new ConsumedCapacity ([
192
+ 'TableName ' => isset ($ item ['TableName ' ]) ? (string ) $ item ['TableName ' ] : null ,
193
+ 'CapacityUnits ' => isset ($ item ['CapacityUnits ' ]) ? (float ) $ item ['CapacityUnits ' ] : null ,
194
+ 'ReadCapacityUnits ' => isset ($ item ['ReadCapacityUnits ' ]) ? (float ) $ item ['ReadCapacityUnits ' ] : null ,
195
+ 'WriteCapacityUnits ' => isset ($ item ['WriteCapacityUnits ' ]) ? (float ) $ item ['WriteCapacityUnits ' ] : null ,
196
+ 'Table ' => empty ($ item ['Table ' ]) ? null : new Capacity ([
197
+ 'ReadCapacityUnits ' => isset ($ item ['Table ' ]['ReadCapacityUnits ' ]) ? (float ) $ item ['Table ' ]['ReadCapacityUnits ' ] : null ,
198
+ 'WriteCapacityUnits ' => isset ($ item ['Table ' ]['WriteCapacityUnits ' ]) ? (float ) $ item ['Table ' ]['WriteCapacityUnits ' ] : null ,
199
+ 'CapacityUnits ' => isset ($ item ['Table ' ]['CapacityUnits ' ]) ? (float ) $ item ['Table ' ]['CapacityUnits ' ] : null ,
200
+ ]),
201
+ 'LocalSecondaryIndexes ' => empty ($ item ['LocalSecondaryIndexes ' ]) ? [] : $ this ->populateResultSecondaryIndexesCapacityMap ($ item ['LocalSecondaryIndexes ' ]),
202
+ 'GlobalSecondaryIndexes ' => empty ($ item ['GlobalSecondaryIndexes ' ]) ? [] : $ this ->populateResultSecondaryIndexesCapacityMap ($ item ['GlobalSecondaryIndexes ' ]),
203
+ ]);
204
+ }
198
205
199
- return $ items ;
200
- };
201
- $ this ->Responses = empty ($ data ['Responses ' ]) ? [] : (function (array $ json ) use (&$ fn ): array {
202
- $ items = [];
203
- foreach ($ json as $ name => $ value ) {
204
- $ items [(string ) $ name ] = $ fn ['list-ItemList ' ]($ value );
206
+ return $ items ;
207
+ }
208
+
209
+ /**
210
+ * @return array[]
211
+ */
212
+ private function populateResultItemList (array $ json ): array
213
+ {
214
+ $ items = [];
215
+ foreach ($ json as $ item ) {
216
+ $ a = empty ($ item ) ? [] : $ this ->populateResultAttributeMap ($ item );
217
+ if (null !== $ a ) {
218
+ $ items [] = $ a ;
205
219
}
220
+ }
221
+
222
+ return $ items ;
223
+ }
224
+
225
+ /**
226
+ * @return array<string, Capacity>
227
+ */
228
+ private function populateResultSecondaryIndexesCapacityMap (array $ json ): array
229
+ {
230
+ $ items = [];
231
+ foreach ($ json as $ name => $ value ) {
232
+ $ items [(string ) $ name ] = Capacity::create ($ value );
233
+ }
206
234
207
- return $ items ;
208
- })($ data ['Responses ' ]);
209
- $ this ->UnprocessedKeys = empty ($ data ['UnprocessedKeys ' ]) ? [] : $ fn ['map-BatchGetRequestMap ' ]($ data ['UnprocessedKeys ' ]);
210
- $ this ->ConsumedCapacity = empty ($ data ['ConsumedCapacity ' ]) ? [] : $ fn ['list-ConsumedCapacityMultiple ' ]($ data ['ConsumedCapacity ' ]);
235
+ return $ items ;
211
236
}
212
237
}
0 commit comments