@@ -61,15 +61,43 @@ public function getItemCollectionMetrics(): ?ItemCollectionMetrics
61
61
protected function populateResult (Response $ response ): void
62
62
{
63
63
$ data = $ response ->toArray ();
64
+ $ fn = [];
65
+ $ fn ['map-AttributeMap ' ] = static function (array $ json ): array {
66
+ $ items = [];
67
+ foreach ($ json as $ name => $ value ) {
68
+ $ items [(string ) $ name ] = AttributeValue::create ($ value );
69
+ }
70
+
71
+ return $ items ;
72
+ };
73
+ $ fn ['map-SecondaryIndexesCapacityMap ' ] = static function (array $ json ): array {
74
+ $ items = [];
75
+ foreach ($ json as $ name => $ value ) {
76
+ $ items [(string ) $ name ] = Capacity::create ($ value );
77
+ }
64
78
65
- $ this ->Attributes = empty ($ data ['Attributes ' ]) ? [] : (function (array $ json ): array {
79
+ return $ items ;
80
+ };
81
+ $ fn ['map-ItemCollectionKeyAttributeMap ' ] = static function (array $ json ): array {
66
82
$ items = [];
67
83
foreach ($ json as $ name => $ value ) {
68
84
$ items [(string ) $ name ] = AttributeValue::create ($ value );
69
85
}
70
86
71
87
return $ items ;
72
- })($ data ['Attributes ' ]);
88
+ };
89
+ $ fn ['list-ItemCollectionSizeEstimateRange ' ] = static function (array $ json ) use (&$ fn ): array {
90
+ $ items = [];
91
+ foreach ($ json as $ item ) {
92
+ $ a = isset ($ item ) ? (float ) $ item : null ;
93
+ if (null !== $ a ) {
94
+ $ items [] = $ a ;
95
+ }
96
+ }
97
+
98
+ return $ items ;
99
+ };
100
+ $ this ->Attributes = empty ($ data ['Attributes ' ]) ? [] : $ fn ['map-AttributeMap ' ]($ data ['Attributes ' ]);
73
101
$ this ->ConsumedCapacity = empty ($ data ['ConsumedCapacity ' ]) ? null : new ConsumedCapacity ([
74
102
'TableName ' => isset ($ data ['ConsumedCapacity ' ]['TableName ' ]) ? (string ) $ data ['ConsumedCapacity ' ]['TableName ' ] : null ,
75
103
'CapacityUnits ' => isset ($ data ['ConsumedCapacity ' ]['CapacityUnits ' ]) ? (float ) $ data ['ConsumedCapacity ' ]['CapacityUnits ' ] : null ,
@@ -80,43 +108,12 @@ protected function populateResult(Response $response): void
80
108
'WriteCapacityUnits ' => isset ($ data ['ConsumedCapacity ' ]['Table ' ]['WriteCapacityUnits ' ]) ? (float ) $ data ['ConsumedCapacity ' ]['Table ' ]['WriteCapacityUnits ' ] : null ,
81
109
'CapacityUnits ' => isset ($ data ['ConsumedCapacity ' ]['Table ' ]['CapacityUnits ' ]) ? (float ) $ data ['ConsumedCapacity ' ]['Table ' ]['CapacityUnits ' ] : null ,
82
110
]),
83
- 'LocalSecondaryIndexes ' => empty ($ data ['ConsumedCapacity ' ]['LocalSecondaryIndexes ' ]) ? [] : (function (array $ json ): array {
84
- $ items = [];
85
- foreach ($ json as $ name => $ value ) {
86
- $ items [(string ) $ name ] = Capacity::create ($ value );
87
- }
88
-
89
- return $ items ;
90
- })($ data ['ConsumedCapacity ' ]['LocalSecondaryIndexes ' ]),
91
- 'GlobalSecondaryIndexes ' => empty ($ data ['ConsumedCapacity ' ]['GlobalSecondaryIndexes ' ]) ? [] : (function (array $ json ): array {
92
- $ items = [];
93
- foreach ($ json as $ name => $ value ) {
94
- $ items [(string ) $ name ] = Capacity::create ($ value );
95
- }
96
-
97
- return $ items ;
98
- })($ data ['ConsumedCapacity ' ]['GlobalSecondaryIndexes ' ]),
111
+ 'LocalSecondaryIndexes ' => empty ($ data ['ConsumedCapacity ' ]['LocalSecondaryIndexes ' ]) ? [] : $ fn ['map-SecondaryIndexesCapacityMap ' ]($ data ['ConsumedCapacity ' ]['LocalSecondaryIndexes ' ]),
112
+ 'GlobalSecondaryIndexes ' => empty ($ data ['ConsumedCapacity ' ]['GlobalSecondaryIndexes ' ]) ? [] : $ fn ['map-SecondaryIndexesCapacityMap ' ]($ data ['ConsumedCapacity ' ]['GlobalSecondaryIndexes ' ]),
99
113
]);
100
114
$ this ->ItemCollectionMetrics = empty ($ data ['ItemCollectionMetrics ' ]) ? null : new ItemCollectionMetrics ([
101
- 'ItemCollectionKey ' => empty ($ data ['ItemCollectionMetrics ' ]['ItemCollectionKey ' ]) ? [] : (function (array $ json ): array {
102
- $ items = [];
103
- foreach ($ json as $ name => $ value ) {
104
- $ items [(string ) $ name ] = AttributeValue::create ($ value );
105
- }
106
-
107
- return $ items ;
108
- })($ data ['ItemCollectionMetrics ' ]['ItemCollectionKey ' ]),
109
- 'SizeEstimateRangeGB ' => empty ($ data ['ItemCollectionMetrics ' ]['SizeEstimateRangeGB ' ]) ? [] : (function (array $ json ): array {
110
- $ items = [];
111
- foreach ($ json as $ item ) {
112
- $ a = isset ($ item ) ? (float ) $ item : null ;
113
- if (null !== $ a ) {
114
- $ items [] = $ a ;
115
- }
116
- }
117
-
118
- return $ items ;
119
- })($ data ['ItemCollectionMetrics ' ]['SizeEstimateRangeGB ' ]),
115
+ 'ItemCollectionKey ' => empty ($ data ['ItemCollectionMetrics ' ]['ItemCollectionKey ' ]) ? [] : $ fn ['map-ItemCollectionKeyAttributeMap ' ]($ data ['ItemCollectionMetrics ' ]['ItemCollectionKey ' ]),
116
+ 'SizeEstimateRangeGB ' => empty ($ data ['ItemCollectionMetrics ' ]['SizeEstimateRangeGB ' ]) ? [] : $ fn ['list-ItemCollectionSizeEstimateRange ' ]($ data ['ItemCollectionMetrics ' ]['SizeEstimateRangeGB ' ]),
120
117
]);
121
118
}
122
119
}
0 commit comments