PHP7 Composite

This commit is contained in:
Dominik Liebler
2016-09-22 20:44:28 +02:00
parent 72f32359c6
commit 320dc3c6bf
7 changed files with 41 additions and 63 deletions

View File

@@ -2,17 +2,20 @@
namespace DesignPatterns\Structural\Composite;
class TextElement extends FormElement
class TextElement implements RenderableInterface
{
/**
* renders the text element.
*
* @param int $indent
*
* @return mixed|string
* @var string
*/
public function render($indent = 0)
private $text;
public function __construct(string $text)
{
return str_repeat(' ', $indent).'this is a text element';
$this->text = $text;
}
public function render(): string
{
return $this->text;
}
}