Completed
Pull Request — master (#325)
by Marc
02:06
created

AbstractRenderable::getNode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace TYPO3Fluid\Fluid\Core\Rendering;
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\Parser\SyntaxTree\NodeInterface;
10
use TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\TextNode;
11
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
12
13
/**
14
 * Class AbstractRenderable
15
 */
16
abstract class AbstractRenderable implements RenderableInterface
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $name;
22
23
    /**
24
     * @var NodeInterface
25
     */
26
    protected $node;
27
28
    /**
29
     * @return string
30
     */
31
    public function getName()
32
    {
33
        return $this->name;
34
    }
35
36
    /**
37
     * @param string $name
38
     * @return RenderableClosure
39
     */
40
    public function setName($name)
41
    {
42
        $this->name = $name;
43
        return $this;
44
    }
45
46
    /**
47
     * @param NodeInterface $node
48
     * @return RenderableClosure
49
     */
50
    public function setNode(NodeInterface $node)
51
    {
52
        $this->node = $node;
53
        return $this;
54
    }
55
56
    /**
57
     * @return NodeInterface
58
     */
59
    public function getNode()
60
    {
61
        return $this->node ? $this->node : new TextNode(sprintf('%s (%s)', static::class, $this->name));
62
    }
63
}
64