Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
8 / 8 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
TemplateFunctionBase | |
100.00% |
8 / 8 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
functionBodyImpl | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
functionBody | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
existsError | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getErrors | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
existsValues | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getValues | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\Core\Mvc\Template\Plugin; |
6 | |
7 | use Smarty\Template; |
8 | use PeServer\Core\Mvc\Template\Plugin\TemplatePluginBase; |
9 | use PeServer\Core\Mvc\Template\Plugin\TemplatePluginArgument; |
10 | |
11 | abstract class TemplateFunctionBase extends TemplatePluginBase implements ITemplateFunction |
12 | { |
13 | #region variable |
14 | |
15 | /** |
16 | * Undocumented variable |
17 | * |
18 | * @var array<string,string> |
19 | */ |
20 | protected array $params; |
21 | |
22 | protected Template $smartyTemplate; |
23 | |
24 | #endregion |
25 | |
26 | protected function __construct(TemplatePluginArgument $argument) |
27 | { |
28 | parent::__construct($argument); |
29 | } |
30 | |
31 | #region function |
32 | |
33 | abstract protected function functionBodyImpl(): string; |
34 | |
35 | #endregion |
36 | |
37 | #region ITemplateBlockFunction |
38 | |
39 | public function functionBody(array $params, Template $smartyTemplate): string |
40 | { |
41 | $this->params = $params; |
42 | $this->smartyTemplate = $smartyTemplate; |
43 | |
44 | return $this->functionBodyImpl(); |
45 | } |
46 | |
47 | #endregion |
48 | |
49 | #region TemplatePluginBase |
50 | |
51 | protected function existsError(): bool |
52 | { |
53 | return $this->existsSmartyError($this->smartyTemplate); |
54 | } |
55 | /** |
56 | * Undocumented function |
57 | * |
58 | * @return array<string,string[]> |
59 | */ |
60 | protected function getErrors(): array |
61 | { |
62 | return $this->getSmartyErrors($this->smartyTemplate); |
63 | } |
64 | |
65 | protected function existsValues(): bool |
66 | { |
67 | return $this->existsSmartyValues($this->smartyTemplate); |
68 | } |
69 | /** |
70 | * Undocumented function |
71 | * |
72 | * @return array<string,string|string[]|bool|int|object> |
73 | */ |
74 | protected function getValues(): array |
75 | { |
76 | return $this->getSmartyValues($this->smartyTemplate); |
77 | } |
78 | |
79 | #endregion |
80 | } |