Completed
Pull Request — master (#214)
by Claus
03:52
created

DefaultRenderMethod   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
buildRenderChildrenClosure() 0 1 ?
renderStatic() 0 5 ?
A render() 0 8 1
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