@@ -172,6 +172,8 @@ private function dumpXmlShape(Member $member, Shape $shape, string $output, stri
172172 return $ this ->dumpXmlShapeNumeric ($ member , $ output , $ input );
173173 case 'boolean ' :
174174 return $ this ->dumpXmlShapeBoolean ($ member , $ output , $ input );
175+ case 'timestamp ' :
176+ return $ this ->dumpXmlShapeTimestamp ($ member , $ output , $ input );
175177 }
176178
177179 throw new \RuntimeException (\sprintf ('Type %s is not yet implemented ' , $ shape ->getType ()));
@@ -303,4 +305,34 @@ private function dumpXmlShapeBoolean(Member $member, string $output, string $inp
303305 'NODE_NAME ' => var_export ($ member ->getLocationName () ?? ($ member instanceof StructureMember ? $ member ->getName () : 'member ' ), true ),
304306 ]);
305307 }
308+
309+ private function dumpXmlShapeTimestamp (Member $ member , string $ output , string $ input ): string
310+ {
311+ $ format = $ member ->getShape ()->get ('timestampFormat ' ) ?? 'iso8601 ' ;
312+ switch ($ format ) {
313+ case 'iso8601 ' :
314+ $ format = 'ATOM ' ;
315+ break ;
316+ case 'rfc822 ' :
317+ $ format = 'RFC822 ' ;
318+ break ;
319+ default :
320+ throw new \RuntimeException (\sprintf ('Timestamp format %s is not yet implemented ' , $ format ));
321+ }
322+
323+ if ($ member instanceof StructureMember && $ member ->isXmlAttribute ()) {
324+ $ body = 'OUTPUT->setAttribute(NODE_NAME, INPUT->format(\DateTimeInterface::FORMAT)); ' ;
325+ } else {
326+ $ body = 'OUTPUT->appendChild($document->createElement(NODE_NAME, INPUT->format(\DateTimeInterface::FORMAT))); ' ;
327+ }
328+
329+ $ replacements = [
330+ 'INPUT ' => $ input ,
331+ 'OUTPUT ' => $ output ,
332+ 'FORMAT ' => $ format ,
333+ 'NODE_NAME ' => var_export ($ member ->getLocationName () ?? ($ member instanceof StructureMember ? $ member ->getName () : 'member ' ), true ),
334+ ];
335+
336+ return strtr ($ body , $ replacements );
337+ }
306338}
0 commit comments