Passed
Push — master ( 1e4b2d...1089a6 )
by Romain
03:52
created

Nl2brTrimViewHelper::compile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 5
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * Copyright (C) 2018
5
 * Nathan Boiron <[email protected]>
6
 * Romain Canon <[email protected]>
7
 *
8
 * This file is part of the TYPO3 NotiZ project.
9
 * It is free software; you can redistribute it and/or modify it
10
 * under the terms of the GNU General Public License, either
11
 * version 3 of the License, or any later version.
12
 *
13
 * For the full copyright and license information, see:
14
 * http://www.gnu.org/licenses/gpl-3.0.html
15
 */
16
17
namespace CuyZ\Notiz\ViewHelpers\Format;
18
19
use TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler;
20
use TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode;
21
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
22
23
class Nl2brTrimViewHelper extends AbstractViewHelper
24
{
25
    /**
26
     * @var bool
27
     */
28
    protected $escapeOutput = false;
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public function render()
34
    {
35
        return \nl2br(\trim($this->renderChildren()));
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
42
    {
43
        return sprintf(
44
            '\nl2br(\trim(%s()))',
45
            $closureName
46
        );
47
    }
48
}
49