@@ -117,14 +117,18 @@ public function __construct(array $input = [])
117117 {
118118 $ this ->TableName = $ input ['TableName ' ] ?? null ;
119119
120- $ this ->Item = [];
121- foreach ($ input ['Item ' ] ?? [] as $ key => $ item ) {
122- $ this ->Item [$ key ] = AttributeValue::create ($ item );
120+ if (isset ($ input ['Item ' ])) {
121+ $ this ->Item = [];
122+ foreach ($ input ['Item ' ] as $ key => $ item ) {
123+ $ this ->Item [$ key ] = AttributeValue::create ($ item );
124+ }
123125 }
124126
125- $ this ->Expected = [];
126- foreach ($ input ['Expected ' ] ?? [] as $ key => $ item ) {
127- $ this ->Expected [$ key ] = ExpectedAttributeValue::create ($ item );
127+ if (isset ($ input ['Expected ' ])) {
128+ $ this ->Expected = [];
129+ foreach ($ input ['Expected ' ] as $ key => $ item ) {
130+ $ this ->Expected [$ key ] = ExpectedAttributeValue::create ($ item );
131+ }
128132 }
129133 $ this ->ReturnValues = $ input ['ReturnValues ' ] ?? null ;
130134 $ this ->ReturnConsumedCapacity = $ input ['ReturnConsumedCapacity ' ] ?? null ;
@@ -133,9 +137,11 @@ public function __construct(array $input = [])
133137 $ this ->ConditionExpression = $ input ['ConditionExpression ' ] ?? null ;
134138 $ this ->ExpressionAttributeNames = $ input ['ExpressionAttributeNames ' ] ?? null ;
135139
136- $ this ->ExpressionAttributeValues = [];
137- foreach ($ input ['ExpressionAttributeValues ' ] ?? [] as $ key => $ item ) {
138- $ this ->ExpressionAttributeValues [$ key ] = AttributeValue::create ($ item );
140+ if (isset ($ input ['ExpressionAttributeValues ' ])) {
141+ $ this ->ExpressionAttributeValues = [];
142+ foreach ($ input ['ExpressionAttributeValues ' ] as $ key => $ item ) {
143+ $ this ->ExpressionAttributeValues [$ key ] = AttributeValue::create ($ item );
144+ }
139145 }
140146 parent ::__construct ($ input );
141147 }
@@ -349,12 +355,22 @@ private function requestBody(): array
349355 throw new InvalidArgument (sprintf ('Missing parameter "Item" for "%s". The value cannot be null. ' , __CLASS__ ));
350356 }
351357
352- foreach ($ v as $ name => $ v ) {
353- $ payload ['Item ' ][$ name ] = $ v ->requestBody ();
358+ if (empty ($ v )) {
359+ $ payload ['Item ' ] = new \stdClass ();
360+ } else {
361+ $ payload ['Item ' ] = [];
362+ foreach ($ v as $ name => $ mv ) {
363+ $ payload ['Item ' ][$ name ] = $ mv ->requestBody ();
364+ }
354365 }
355366 if (null !== $ v = $ this ->Expected ) {
356- foreach ($ v as $ name => $ v ) {
357- $ payload ['Expected ' ][$ name ] = $ v ->requestBody ();
367+ if (empty ($ v )) {
368+ $ payload ['Expected ' ] = new \stdClass ();
369+ } else {
370+ $ payload ['Expected ' ] = [];
371+ foreach ($ v as $ name => $ mv ) {
372+ $ payload ['Expected ' ][$ name ] = $ mv ->requestBody ();
373+ }
358374 }
359375 }
360376 if (null !== $ v = $ this ->ReturnValues ) {
@@ -385,13 +401,23 @@ private function requestBody(): array
385401 $ payload ['ConditionExpression ' ] = $ v ;
386402 }
387403 if (null !== $ v = $ this ->ExpressionAttributeNames ) {
388- foreach ($ v as $ name => $ v ) {
389- $ payload ['ExpressionAttributeNames ' ][$ name ] = $ v ;
404+ if (empty ($ v )) {
405+ $ payload ['ExpressionAttributeNames ' ] = new \stdClass ();
406+ } else {
407+ $ payload ['ExpressionAttributeNames ' ] = [];
408+ foreach ($ v as $ name => $ mv ) {
409+ $ payload ['ExpressionAttributeNames ' ][$ name ] = $ mv ;
410+ }
390411 }
391412 }
392413 if (null !== $ v = $ this ->ExpressionAttributeValues ) {
393- foreach ($ v as $ name => $ v ) {
394- $ payload ['ExpressionAttributeValues ' ][$ name ] = $ v ->requestBody ();
414+ if (empty ($ v )) {
415+ $ payload ['ExpressionAttributeValues ' ] = new \stdClass ();
416+ } else {
417+ $ payload ['ExpressionAttributeValues ' ] = [];
418+ foreach ($ v as $ name => $ mv ) {
419+ $ payload ['ExpressionAttributeValues ' ][$ name ] = $ mv ->requestBody ();
420+ }
395421 }
396422 }
397423
0 commit comments