@@ -23,7 +23,7 @@ final class CreateTableInput extends Input
2323 *
2424 * @required
2525 *
26- * @var AttributeDefinition[]
26+ * @var AttributeDefinition[]|null
2727 */
2828 private $ AttributeDefinitions ;
2929
@@ -44,7 +44,7 @@ final class CreateTableInput extends Input
4444 * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html
4545 * @required
4646 *
47- * @var KeySchemaElement[]
47+ * @var KeySchemaElement[]|null
4848 */
4949 private $ KeySchema ;
5050
@@ -53,15 +53,15 @@ final class CreateTableInput extends Input
5353 * partition key value. There is a 10 GB size limit per partition key value; otherwise, the size of a local secondary
5454 * index is unconstrained.
5555 *
56- * @var LocalSecondaryIndex[]
56+ * @var LocalSecondaryIndex[]|null
5757 */
5858 private $ LocalSecondaryIndexes ;
5959
6060 /**
6161 * One or more global secondary indexes (the maximum is 20) to be created on the table. Each global secondary index in
6262 * the array includes the following:.
6363 *
64- * @var GlobalSecondaryIndex[]
64+ * @var GlobalSecondaryIndex[]|null
6565 */
6666 private $ GlobalSecondaryIndexes ;
6767
@@ -100,7 +100,7 @@ final class CreateTableInput extends Input
100100 *
101101 * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tagging.html
102102 *
103- * @var Tag[]
103+ * @var Tag[]|null
104104 */
105105 private $ Tags ;
106106
@@ -121,16 +121,16 @@ final class CreateTableInput extends Input
121121 */
122122 public function __construct (array $ input = [])
123123 {
124- $ this ->AttributeDefinitions = array_map ([AttributeDefinition::class, 'create ' ], $ input ['AttributeDefinitions ' ] ?? []) ;
124+ $ this ->AttributeDefinitions = isset ( $ input [ ' AttributeDefinitions ' ]) ? array_map ([AttributeDefinition::class, 'create ' ], $ input ['AttributeDefinitions ' ]) : null ;
125125 $ this ->TableName = $ input ['TableName ' ] ?? null ;
126- $ this ->KeySchema = array_map ([KeySchemaElement::class, 'create ' ], $ input ['KeySchema ' ] ?? []) ;
127- $ this ->LocalSecondaryIndexes = array_map ([LocalSecondaryIndex::class, 'create ' ], $ input ['LocalSecondaryIndexes ' ] ?? []) ;
128- $ this ->GlobalSecondaryIndexes = array_map ([GlobalSecondaryIndex::class, 'create ' ], $ input ['GlobalSecondaryIndexes ' ] ?? []) ;
126+ $ this ->KeySchema = isset ( $ input [ ' KeySchema ' ]) ? array_map ([KeySchemaElement::class, 'create ' ], $ input ['KeySchema ' ]) : null ;
127+ $ this ->LocalSecondaryIndexes = isset ( $ input [ ' LocalSecondaryIndexes ' ]) ? array_map ([LocalSecondaryIndex::class, 'create ' ], $ input ['LocalSecondaryIndexes ' ]) : null ;
128+ $ this ->GlobalSecondaryIndexes = isset ( $ input [ ' GlobalSecondaryIndexes ' ]) ? array_map ([GlobalSecondaryIndex::class, 'create ' ], $ input ['GlobalSecondaryIndexes ' ]) : null ;
129129 $ this ->BillingMode = $ input ['BillingMode ' ] ?? null ;
130130 $ this ->ProvisionedThroughput = isset ($ input ['ProvisionedThroughput ' ]) ? ProvisionedThroughput::create ($ input ['ProvisionedThroughput ' ]) : null ;
131131 $ this ->StreamSpecification = isset ($ input ['StreamSpecification ' ]) ? StreamSpecification::create ($ input ['StreamSpecification ' ]) : null ;
132132 $ this ->SSESpecification = isset ($ input ['SSESpecification ' ]) ? SSESpecification::create ($ input ['SSESpecification ' ]) : null ;
133- $ this ->Tags = array_map ([Tag::class, 'create ' ], $ input ['Tags ' ] ?? []) ;
133+ $ this ->Tags = isset ( $ input [ ' Tags ' ]) ? array_map ([Tag::class, 'create ' ], $ input ['Tags ' ]) : null ;
134134 parent ::__construct ($ input );
135135 }
136136
@@ -144,7 +144,7 @@ public static function create($input): self
144144 */
145145 public function getAttributeDefinitions (): array
146146 {
147- return $ this ->AttributeDefinitions ;
147+ return $ this ->AttributeDefinitions ?? [] ;
148148 }
149149
150150 /**
@@ -160,23 +160,23 @@ public function getBillingMode(): ?string
160160 */
161161 public function getGlobalSecondaryIndexes (): array
162162 {
163- return $ this ->GlobalSecondaryIndexes ;
163+ return $ this ->GlobalSecondaryIndexes ?? [] ;
164164 }
165165
166166 /**
167167 * @return KeySchemaElement[]
168168 */
169169 public function getKeySchema (): array
170170 {
171- return $ this ->KeySchema ;
171+ return $ this ->KeySchema ?? [] ;
172172 }
173173
174174 /**
175175 * @return LocalSecondaryIndex[]
176176 */
177177 public function getLocalSecondaryIndexes (): array
178178 {
179- return $ this ->LocalSecondaryIndexes ;
179+ return $ this ->LocalSecondaryIndexes ?? [] ;
180180 }
181181
182182 public function getProvisionedThroughput (): ?ProvisionedThroughput
@@ -204,7 +204,7 @@ public function getTableName(): ?string
204204 */
205205 public function getTags (): array
206206 {
207- return $ this ->Tags ;
207+ return $ this ->Tags ?? [] ;
208208 }
209209
210210 /**
@@ -323,9 +323,13 @@ public function setTags(array $value): self
323323 private function requestBody (): array
324324 {
325325 $ payload = [];
326+ if (null === $ v = $ this ->AttributeDefinitions ) {
327+ throw new InvalidArgument (sprintf ('Missing parameter "AttributeDefinitions" for "%s". The value cannot be null. ' , __CLASS__ ));
328+ }
326329
327330 $ index = -1 ;
328- foreach ($ this ->AttributeDefinitions as $ listValue ) {
331+ $ payload ['AttributeDefinitions ' ] = [];
332+ foreach ($ v as $ listValue ) {
329333 ++$ index ;
330334 $ payload ['AttributeDefinitions ' ][$ index ] = $ listValue ->requestBody ();
331335 }
@@ -334,25 +338,33 @@ private function requestBody(): array
334338 throw new InvalidArgument (sprintf ('Missing parameter "TableName" for "%s". The value cannot be null. ' , __CLASS__ ));
335339 }
336340 $ payload ['TableName ' ] = $ v ;
341+ if (null === $ v = $ this ->KeySchema ) {
342+ throw new InvalidArgument (sprintf ('Missing parameter "KeySchema" for "%s". The value cannot be null. ' , __CLASS__ ));
343+ }
337344
338345 $ index = -1 ;
339- foreach ($ this ->KeySchema as $ listValue ) {
346+ $ payload ['KeySchema ' ] = [];
347+ foreach ($ v as $ listValue ) {
340348 ++$ index ;
341349 $ payload ['KeySchema ' ][$ index ] = $ listValue ->requestBody ();
342350 }
343351
344- $ index = -1 ;
345- foreach ($ this ->LocalSecondaryIndexes as $ listValue ) {
346- ++$ index ;
347- $ payload ['LocalSecondaryIndexes ' ][$ index ] = $ listValue ->requestBody ();
352+ if (null !== $ v = $ this ->LocalSecondaryIndexes ) {
353+ $ index = -1 ;
354+ $ payload ['LocalSecondaryIndexes ' ] = [];
355+ foreach ($ v as $ listValue ) {
356+ ++$ index ;
357+ $ payload ['LocalSecondaryIndexes ' ][$ index ] = $ listValue ->requestBody ();
358+ }
348359 }
349-
350- $ index = -1 ;
351- foreach ($ this ->GlobalSecondaryIndexes as $ listValue ) {
352- ++$ index ;
353- $ payload ['GlobalSecondaryIndexes ' ][$ index ] = $ listValue ->requestBody ();
360+ if (null !== $ v = $ this ->GlobalSecondaryIndexes ) {
361+ $ index = -1 ;
362+ $ payload ['GlobalSecondaryIndexes ' ] = [];
363+ foreach ($ v as $ listValue ) {
364+ ++$ index ;
365+ $ payload ['GlobalSecondaryIndexes ' ][$ index ] = $ listValue ->requestBody ();
366+ }
354367 }
355-
356368 if (null !== $ v = $ this ->BillingMode ) {
357369 if (!BillingMode::exists ($ v )) {
358370 throw new InvalidArgument (sprintf ('Invalid parameter "BillingMode" for "%s". The value "%s" is not a valid "BillingMode". ' , __CLASS__ , $ v ));
@@ -368,11 +380,13 @@ private function requestBody(): array
368380 if (null !== $ v = $ this ->SSESpecification ) {
369381 $ payload ['SSESpecification ' ] = $ v ->requestBody ();
370382 }
371-
372- $ index = -1 ;
373- foreach ($ this ->Tags as $ listValue ) {
374- ++$ index ;
375- $ payload ['Tags ' ][$ index ] = $ listValue ->requestBody ();
383+ if (null !== $ v = $ this ->Tags ) {
384+ $ index = -1 ;
385+ $ payload ['Tags ' ] = [];
386+ foreach ($ v as $ listValue ) {
387+ ++$ index ;
388+ $ payload ['Tags ' ][$ index ] = $ listValue ->requestBody ();
389+ }
376390 }
377391
378392 return $ payload ;
0 commit comments