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