From 6b77eb71e662eb240c4eabde494178bdb9562b42 Mon Sep 17 00:00:00 2001 From: Trismegiste Date: Sat, 11 May 2013 02:51:57 +0200 Subject: [PATCH] spacing --- Decorator/Decorator.php | 8 ++++---- Decorator/RenderInJson.php | 2 ++ Decorator/RenderInXml.php | 4 +++- Decorator/Renderer.php | 3 ++- Decorator/Webservice.php | 2 ++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Decorator/Decorator.php b/Decorator/Decorator.php index 3231f09..d7ab5dd 100644 --- a/Decorator/Decorator.php +++ b/Decorator/Decorator.php @@ -14,17 +14,17 @@ namespace DesignPatterns\Decorator; * course) * */ - -/** +/** * the Deoorator MUST implement the Renderer contract, this is the key-feature * of this design pattern. If not, this is no longer a Decorator but just a dumb * wrapper. */ abstract class Decorator implements Renderer { + protected $_wrapped; - + /** * You must type-hint the wrapped component : * It ensures you can call renderData() in the subclasses ! @@ -35,5 +35,5 @@ abstract class Decorator implements Renderer { $this->_wrapped = $wrappable; } -} +} diff --git a/Decorator/RenderInJson.php b/Decorator/RenderInJson.php index 57f8b06..0c521bd 100644 --- a/Decorator/RenderInJson.php +++ b/Decorator/RenderInJson.php @@ -4,9 +4,11 @@ namespace DesignPatterns\Decorator; class RenderInJson extends Decorator { + public function renderData() { $output = $this->_wrapped->renderData(); return json_encode($output); } + } diff --git a/Decorator/RenderInXml.php b/Decorator/RenderInXml.php index 6e594f9..599c2f5 100644 --- a/Decorator/RenderInXml.php +++ b/Decorator/RenderInXml.php @@ -4,6 +4,7 @@ namespace DesignPatterns\Decorator; class RenderInXml extends Decorator { + public function renderData() { $output = $this->_wrapped->renderData(); @@ -12,7 +13,8 @@ class RenderInXml extends Decorator foreach ($output as $key => $val) { $doc->appendChild($doc->createElement('foo', 'bar')); } - + return $doc->saveXML(); } + } diff --git a/Decorator/Renderer.php b/Decorator/Renderer.php index 6a01d4e..af3c46b 100644 --- a/Decorator/Renderer.php +++ b/Decorator/Renderer.php @@ -1,8 +1,9 @@ _data; } + }