WrapViewHelper::renderStatic()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 5
nc 2
nop 3
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Qbus\Qbtools\ViewHelpers;
3
4
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
5
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
6
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
7
8
/**
9
 * WrapViewHelper
10
 *
11
 * @author Benjamin Franzke <[email protected]>
12
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
13
 */
14
class WrapViewHelper extends AbstractViewHelper
15
{
16
    use CompileWithRenderStatic;
17
18
    /**
19
     * @var bool
20
     */
21
    protected $escapeOutput = false;
22
23
    /**
24
     * Initialize arguments
25
     */
26
    public function initializeArguments()
27
    {
28
        $this->registerArgument('class', 'string', '', true);
29
    }
30
31
    /**
32
     * @param array $arguments
33
     * @param \Closure $renderChildrenClosure
34
     * @param RenderingContextInterface $renderingContext
35
     * @return string
36
     */
37
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
38
    {
39
        $class = $arguments['class'];
40
41
        $content = $renderChildrenClosure();
42
        if (ctype_space($content) || $content === '' || $content === null) {
43
            return '';
44
        }
45
46
        return '<div class="' . htmlspecialchars($class) . '">' . $content . '</div>';
47
    }
48
}
49