@@ -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,36 @@ 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+
316+ break ;
317+ case 'rfc822 ' :
318+ $ format = 'RFC822 ' ;
319+
320+ break ;
321+ default :
322+ throw new \RuntimeException (\sprintf ('Timestamp format %s is not yet implemented ' , $ format ));
323+ }
324+
325+ if ($ member instanceof StructureMember && $ member ->isXmlAttribute ()) {
326+ $ body = 'OUTPUT->setAttribute(NODE_NAME, INPUT->format(\DateTimeInterface::FORMAT)); ' ;
327+ } else {
328+ $ body = 'OUTPUT->appendChild($document->createElement(NODE_NAME, INPUT->format(\DateTimeInterface::FORMAT))); ' ;
329+ }
330+
331+ $ replacements = [
332+ 'INPUT ' => $ input ,
333+ 'OUTPUT ' => $ output ,
334+ 'FORMAT ' => $ format ,
335+ 'NODE_NAME ' => var_export ($ member ->getLocationName () ?? ($ member instanceof StructureMember ? $ member ->getName () : 'member ' ), true ),
336+ ];
337+
338+ return strtr ($ body , $ replacements );
339+ }
306340}
0 commit comments