mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-11 01:14:01 +02:00
PHP7 Composite
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user