Completed
Pull Request — master (#214)
by Claus
03:52
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
     * @var array
19
     */
20
    protected $arguments = [];
21
22
    /**
23
     * @var RenderingContextInterface
24
     */
25
    protected $renderingContext;
26
27
    /**
28
     * Forced implementation to build a rendering closure
29
     *
30
     * @return \Closure
31
     */
32
    abstract public function buildRenderChildrenClosure();
33
34
    /**
35
     * @return mixed
36
     */
37
    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...
38
        array $arguments,
39
        \Closure $renderChildrenClosure,
40
        RenderingContextInterface $renderingContext
41
    );
42
43
    /**
44
     * Default render method to render ViewHelper with
45
     * first defined optional argument as content.
46
     *
47
     * @return string Rendered string
48
     * @api
49
     */
50
    public function render()
51
    {
52
        return self::renderStatic(
53
            $this->arguments,
54
            $this->buildRenderChildrenClosure(),
55
            $this->renderingContext
56
        );
57
    }
58
}
59