mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-10 08:54:03 +02:00
PHP7 Decorator
This commit is contained in:
15
Structural/Decorator/XmlRenderer.php
Normal file
15
Structural/Decorator/XmlRenderer.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Structural\Decorator;
|
||||
|
||||
class XmlRenderer extends RendererDecorator
|
||||
{
|
||||
public function renderData(): string
|
||||
{
|
||||
$doc = new \DOMDocument();
|
||||
$data = $this->wrapped->renderData();
|
||||
$doc->appendChild($doc->createElement('content', $data));
|
||||
|
||||
return $doc->saveXML();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user