fix PSR-0

This commit is contained in:
Trismegiste
2013-05-11 02:50:05 +02:00
parent cfa9014906
commit 55017fb43f
5 changed files with 56 additions and 46 deletions

View File

@@ -15,25 +15,6 @@ namespace DesignPatterns\Decorator;
*
*/
interface Renderer
{
public function renderData();
}
class Webservice implements Renderer
{
protected $_data;
public function __construct($data)
{
$this->_data = $data;
}
public function renderData()
{
return $this->_data;
}
}
/**
* the Deoorator MUST implement the Renderer contract, this is the key-feature
@@ -56,30 +37,3 @@ abstract class Decorator implements Renderer
}
}
class RenderInJson extends Decorator
{
public function renderData()
{
$output = $this->_wrapped->renderData();
return json_encode($output);
}
}
class RenderInXml extends Decorator
{
public function renderData()
{
$output = $this->_wrapped->renderData();
// do some fany conversion to xml from array ...
return simplexml_load_string($output);
}
}
// Create a normal service
$service = new Webservice(array('foo' => 'bar'));
// Wrap service with a JSON decorator for renderers
$service = new RenderInJson($service);
// Our Renderer will now output JSON instead of an array
echo $service->renderData();