mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-10-03 09:42:31 +02:00
start a restructure
This commit is contained in:
31
Structural/Decorator/Decorator.php
Normal file
31
Structural/Decorator/Decorator.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Decorator;
|
||||
|
||||
/**
|
||||
* the Decorator MUST implement the RendererInterface contract, this is the key-feature
|
||||
* of this design pattern. If not, this is no longer a Decorator but just a dumb
|
||||
* wrapper.
|
||||
*/
|
||||
|
||||
/**
|
||||
* class Decorator
|
||||
*/
|
||||
abstract class Decorator implements RendererInterface
|
||||
{
|
||||
/**
|
||||
* @var RendererInterface
|
||||
*/
|
||||
protected $wrapped;
|
||||
|
||||
/**
|
||||
* You must type-hint the wrapped component :
|
||||
* It ensures you can call renderData() in the subclasses !
|
||||
*
|
||||
* @param RendererInterface $wrappable
|
||||
*/
|
||||
public function __construct(RendererInterface $wrappable)
|
||||
{
|
||||
$this->wrapped = $wrappable;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user