Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| AbstractTemplate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| getTemplate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setTemplate | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| render | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| renderTemplate | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| 1 | <?php |
| 2 | /** |
| 3 | * Pop PHP Framework (https://www.popphp.org/) |
| 4 | * |
| 5 | * @link https://github.com/popphp/popphp-framework |
| 6 | * @author Nick Sagona, III <dev@noladev.com> |
| 7 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 8 | * @license https://www.popphp.org/license New BSD License |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * @namespace |
| 13 | */ |
| 14 | namespace Pop\View\Template; |
| 15 | |
| 16 | /** |
| 17 | * View template abstract class |
| 18 | * |
| 19 | * @category Pop |
| 20 | * @package Pop\View |
| 21 | * @author Nick Sagona, III <dev@noladev.com> |
| 22 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 23 | * @license https://www.popphp.org/license New BSD License |
| 24 | * @version 4.0.4 |
| 25 | */ |
| 26 | abstract class AbstractTemplate implements TemplateInterface |
| 27 | { |
| 28 | |
| 29 | /** |
| 30 | * View template |
| 31 | * @var ?string |
| 32 | */ |
| 33 | protected ?string $template = null; |
| 34 | |
| 35 | /** |
| 36 | * View data |
| 37 | * @var array |
| 38 | */ |
| 39 | protected array $data = []; |
| 40 | |
| 41 | /** |
| 42 | * View output string |
| 43 | * @var ?string |
| 44 | */ |
| 45 | protected ?string $output = null; |
| 46 | |
| 47 | /** |
| 48 | * Get view template |
| 49 | * |
| 50 | * @return string |
| 51 | */ |
| 52 | public function getTemplate(): string |
| 53 | { |
| 54 | return $this->template; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Set view template |
| 59 | * |
| 60 | * @param string $template |
| 61 | * @return AbstractTemplate |
| 62 | */ |
| 63 | abstract public function setTemplate(string $template): AbstractTemplate; |
| 64 | |
| 65 | /** |
| 66 | * Render the view and return the output |
| 67 | * |
| 68 | * @param array $data |
| 69 | * @return string |
| 70 | */ |
| 71 | abstract public function render(array $data): string; |
| 72 | |
| 73 | /** |
| 74 | * Render view template file |
| 75 | * |
| 76 | * @return void |
| 77 | */ |
| 78 | abstract protected function renderTemplate(): void; |
| 79 | |
| 80 | } |