Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
70.00% covered (warning)
70.00%
7 / 10
25.00% covered (danger)
25.00%
1 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
TemplateBlockFunctionBase
70.00% covered (warning)
70.00%
7 / 10
25.00% covered (danger)
25.00%
1 / 4
6.97
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 functionBlockBodyImpl
n/a
0 / 0
n/a
0 / 0
0
 functionBlockBody
85.71% covered (warning)
85.71%
6 / 7
0.00% covered (danger)
0.00%
0 / 1
3.03
 functionBodyImpl
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 functionBody
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace PeServer\Core\Mvc\Template\Plugin;
6
7use TypeError;
8use Smarty\Template;
9use PeServer\Core\Text;
10use PeServer\Core\Throws\NotSupportedException;
11use PeServer\Core\Mvc\Template\Plugin\TemplateFunctionBase;
12use PeServer\Core\Mvc\Template\Plugin\TemplatePluginArgument;
13
14abstract class TemplateBlockFunctionBase extends TemplateFunctionBase implements ITemplateBlockFunction
15{
16    protected function __construct(TemplatePluginArgument $argument)
17    {
18        parent::__construct($argument);
19    }
20
21    #region function
22
23    abstract protected function functionBlockBodyImpl(string $content): string;
24
25    #endregion
26
27    #region ITemplateBlockFunction
28
29    public function functionBlockBody(array $params, mixed $content, Template $template, bool &$repeat): string
30    {
31        if ($repeat) {
32            $this->params = $params;
33            $this->smartyTemplate = $template;
34
35            return Text::EMPTY;
36        }
37
38        if (!is_string($content)) {
39            throw new TypeError();
40        }
41
42        return $this->functionBlockBodyImpl((string)$content);
43    }
44
45    #endregion
46
47    #region TemplateFunctionBase
48
49    final protected function functionBodyImpl(): string
50    {
51        throw new NotSupportedException();
52    }
53
54    final public function functionBody(array $params, Template $smarty): string
55    {
56        throw new NotSupportedException();
57    }
58
59    #endregion
60}