WrapViewHelper   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 9
c 3
b 0
f 0
dl 0
loc 33
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderStatic() 0 10 4
A initializeArguments() 0 3 1
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