Completed
Push — master ( eefd63...5abf6c )
by
unknown
52:28 queued 34:12
created

NoSpaceViewHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderStatic() 0 3 1
A initializeArguments() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
namespace TYPO3\CMS\Install\ViewHelpers\Format;
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
20
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
21
22
/**
23
 * Remove all spaces in a string
24
 *
25
 * @internal
26
 */
27
class NoSpaceViewHelper extends AbstractViewHelper
28
{
29
    use CompileWithRenderStatic;
30
31
    /**
32
     * Initialize arguments
33
     */
34
    public function initializeArguments(): void
35
    {
36
        parent::initializeArguments();
37
        $this->registerArgument('value', 'string', '', true);
38
    }
39
40
    /**
41
     * Render a string with whitespaces stripped
42
     *
43
     * @param array $arguments
44
     * @param \Closure $renderChildrenClosure
45
     * @param RenderingContextInterface $renderingContext
46
     *
47
     * @return string
48
     */
49
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
50
    {
51
        return preg_replace('/\s+/', '', $arguments['value']);
52
    }
53
}
54