Completed
Pull Request — master (#214)
by Claus
04:41 queued 01:05
created

DefaultRenderMethod::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace TYPO3Fluid\Fluid\Core\ViewHelper\Traits;
3
4
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
5
6
/**
7
 * Class DefaultRenderMethod
8
 *
9
 * Contains a default implementation of a render method which calls
10
 * renderStatic.
11
 *
12
 * Implement this trait to indicate that your ViewHelper is exclusively
13
 * static callable and implements renderStatic().
14
 */
15
trait DefaultRenderMethod
16
{
17
    /**
18
     * Forced implementation to build a rendering closure
19
     *
20
     * @return \Closure
21
     */
22
    abstract public function buildRenderChildrenClosure();
23
24
    /**
25
     * @return mixed
26
     */
27
    abstract static function renderStatic(
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
28
        array $arguments,
29
        \Closure $renderChildrenClosure,
30
        RenderingContextInterface $renderingContext
31
    );
32
33
    /**
34
     * Default render method to render ViewHelper with
35
     * first defined optional argument as content.
36
     *
37
     * @return string Rendered string
38
     * @api
39
     */
40
    public function render()
41
    {
42
        return static::renderStatic(
43
            $this->arguments,
0 ignored issues
show
Bug introduced by
The property arguments does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
44
            $this->buildRenderChildrenClosure(),
45
            $this->renderingContext
0 ignored issues
show
Bug introduced by
The property renderingContext does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
46
        );
47
    }
48
}
49