fixed return type of RendererInterface

This commit is contained in:
Dominik Liebler
2016-05-13 10:23:19 +02:00
parent 3fcf860cf3
commit acdef3f6e9
3 changed files with 5 additions and 9 deletions

View File

@@ -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);
} }
} }

View File

@@ -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));
} }

View File

@@ -10,7 +10,7 @@ interface RendererInterface
/** /**
* render data. * render data.
* *
* @return mixed * @return string
*/ */
public function renderData(); public function renderData();
} }