mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 20:20:15 +02:00
start a restructure
This commit is contained in:
29
Structural/Decorator/RenderInXml.php
Normal file
29
Structural/Decorator/RenderInXml.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Decorator;
|
||||
|
||||
/**
|
||||
* Class RenderInXml
|
||||
*/
|
||||
class RenderInXml extends Decorator
|
||||
{
|
||||
/**
|
||||
* render data as XML
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function renderData()
|
||||
{
|
||||
$output = $this->wrapped->renderData();
|
||||
|
||||
// do some fancy conversion to xml from array ...
|
||||
|
||||
$doc = new \DOMDocument();
|
||||
|
||||
foreach ($output as $key => $val) {
|
||||
$doc->appendChild($doc->createElement($key, $val));
|
||||
}
|
||||
|
||||
return $doc->saveXML();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user