Total Complexity | 4 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
21 | class Context |
||
22 | { |
||
23 | /** |
||
24 | * @var Engine |
||
25 | */ |
||
26 | private $__engine__; |
||
27 | |||
28 | /** |
||
29 | * The constructor |
||
30 | * |
||
31 | * @param Engine $engine |
||
32 | * @param array $aVars The template vars |
||
33 | */ |
||
34 | public function __construct(Engine $engine, array $aVars) |
||
35 | { |
||
36 | $this->__engine__ = $engine; |
||
37 | foreach($aVars as $sName => $xValue) |
||
38 | { |
||
39 | $sName = (string)$sName; |
||
40 | $this->$sName = $xValue; |
||
41 | } |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Render a template |
||
46 | * |
||
47 | * @param string $sTemplate The name of template to be rendered |
||
48 | * @param array $aVars The template vars |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | public function render(string $sTemplate, array $aVars = []): string |
||
53 | { |
||
54 | return $this->__engine__->render($sTemplate, $aVars); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Include a template |
||
59 | * |
||
60 | * @param string $sTemplate The name of template to be rendered |
||
61 | * @param array $aVars The template vars |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | public function include(string $sTemplate, array $aVars = []) |
||
68 | } |
||
69 | } |
||
70 |