Completed
Pull Request — master (#446)
by Claus
02:04
created

ThenViewHelper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 14.58 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 7
loc 48
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 4 1
A allowsChildNodeType() 7 7 3
A compile() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace TYPO3Fluid\Fluid\ViewHelpers;
3
4
/*
5
 * This file belongs to the package "TYPO3 Fluid".
6
 * See LICENSE.txt that was shipped with this package.
7
 */
8
9
use TYPO3Fluid\Fluid\Core\Compiler\TemplateCompiler;
10
use TYPO3Fluid\Fluid\Core\Parser\NodeFilterInterface;
11
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\NodeInterface;
12
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\TextNode;
13
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\ViewHelperNode;
14
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
15
16
/**
17
 * "THEN" -> only has an effect inside of "IF". See If-ViewHelper for documentation.
18
 *
19
 * @see \TYPO3Fluid\Fluid\ViewHelpers\IfViewHelper
20
 * @api
21
 */
22
class ThenViewHelper extends AbstractViewHelper implements NodeFilterInterface
23
{
24
25
    /**
26
     * @var boolean
27
     */
28
    protected $escapeOutput = false;
29
30
    /**
31
     * Just render everything.
32
     *
33
     * @return string the rendered string
34
     * @api
35
     */
36
    public function render()
37
    {
38
        return $this->renderChildren();
39
    }
40
41
    /**
42
     * Condition ViewHelpers disallow child nodes that consist purely of whitespace,
43
     * thus avoiding whitespace in output inside f:if structures but not inside any
44
     * f:then or f:else nodes.
45
     *
46
     * @param NodeInterface $node
47
     * @return bool
48
     */
49 View Code Duplication
    public function allowsChildNodeType(NodeInterface $node): bool
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50
    {
51
        if ($node instanceof TextNode && trim($node->getText()) === '') {
52
            return false;
53
        }
54
        return true;
55
    }
56
57
    /**
58
     * @param string $argumentsName
59
     * @param string $closureName
60
     * @param string $initializationPhpCode
61
     * @param ViewHelperNode $node
62
     * @param TemplateCompiler $compiler
63
     * @return string
64
     */
65
    public function compile($argumentsName, $closureName, &$initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
66
    {
67
        return '\'\'';
68
    }
69
}
70