| Total Complexity | 5 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Tarsana\Command\Template\Twig; |
||
| 5 | class TwigTemplate implements TemplateInterface { |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Twig template instance. |
||
| 9 | */ |
||
| 10 | protected $twig; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Data to pass to the template. |
||
| 14 | * |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | protected $data; |
||
| 18 | |||
| 19 | public function __construct ($twig) |
||
| 20 | { |
||
| 21 | $this->twig = $twig; |
||
| 22 | $this->data = []; |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Binds data to the template. |
||
| 27 | * |
||
| 28 | * @param array $data |
||
| 29 | * @return self |
||
| 30 | */ |
||
| 31 | public function bind (array $data) : TemplateInterface |
||
| 32 | { |
||
| 33 | $this->data = array_merge($this->data, $data); |
||
| 34 | return $this; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Renders the template. |
||
| 39 | * |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | public function render(array $data = null) : string |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Clears the data. |
||
| 52 | * |
||
| 53 | * @return self |
||
| 54 | */ |
||
| 55 | public function clear () : TemplateInterface |
||
| 59 | } |
||
| 60 | } |
||
| 61 |