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