mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-17 05:11:18 +02:00
fixed return type of RendererInterface
This commit is contained in:
@@ -10,12 +10,10 @@ class RenderInJson extends Decorator
|
|||||||
/**
|
/**
|
||||||
* render data as JSON.
|
* render data as JSON.
|
||||||
*
|
*
|
||||||
* @return mixed|string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function renderData()
|
public function renderData()
|
||||||
{
|
{
|
||||||
$output = $this->wrapped->renderData();
|
return json_encode($this->wrapped->renderData());
|
||||||
|
|
||||||
return json_encode($output);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,17 +10,15 @@ class RenderInXml extends Decorator
|
|||||||
/**
|
/**
|
||||||
* render data as XML.
|
* render data as XML.
|
||||||
*
|
*
|
||||||
* @return mixed|string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function renderData()
|
public function renderData()
|
||||||
{
|
{
|
||||||
$output = $this->wrapped->renderData();
|
|
||||||
|
|
||||||
// do some fancy conversion to xml from array ...
|
// do some fancy conversion to xml from array ...
|
||||||
|
|
||||||
$doc = new \DOMDocument();
|
$doc = new \DOMDocument();
|
||||||
|
|
||||||
foreach ($output as $key => $val) {
|
foreach ($this->wrapped->renderData() as $key => $val) {
|
||||||
$doc->appendChild($doc->createElement($key, $val));
|
$doc->appendChild($doc->createElement($key, $val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ interface RendererInterface
|
|||||||
/**
|
/**
|
||||||
* render data.
|
* render data.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function renderData();
|
public function renderData();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user