mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-05 21:46:21 +02:00
fixing the inheritance tree for decorator
This commit is contained in:
parent
794139d47c
commit
97096bc23f
@ -35,17 +35,28 @@ class Webservice implements Renderer
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Decorator
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public function __construct($wrappable)
|
||||
/**
|
||||
* You must type-hint the wrapped component :
|
||||
* It ensures you can call renderData() in the subclasses !
|
||||
*
|
||||
* @param Renderer $wrappable
|
||||
*/
|
||||
public function __construct(Renderer $wrappable)
|
||||
{
|
||||
$this->_wrapped = $wrappable;
|
||||
}
|
||||
}
|
||||
|
||||
class RenderInJson extends Decorator implements Renderer
|
||||
class RenderInJson extends Decorator
|
||||
{
|
||||
public function renderData()
|
||||
{
|
||||
@ -54,7 +65,7 @@ class RenderInJson extends Decorator implements Renderer
|
||||
}
|
||||
}
|
||||
|
||||
class RenderInXml extends Decorator implements Renderer
|
||||
class RenderInXml extends Decorator
|
||||
{
|
||||
public function renderData()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user