Completed
Push — master ( a378d5...7b6893 )
by Flo
28s
created

RenderBlock::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 3
1
<?php
2
/**
3
 * Class RenderBlock | RenderBlock.php
4
 * @package Faulancer\View\Helper
5
 * @author  Florian Knapp <[email protected]>
6
 */
7
namespace Faulancer\View\Helper;
8
9
use Faulancer\View\AbstractViewHelper;
10
use Faulancer\View\ViewController;
11
12
/**
13
 * Class RenderBlock
14
 */
15
class RenderBlock extends AbstractViewHelper
16
{
17
18
    /**
19
     * Render a defined block from variable
20
     *
21
     * @param ViewController $view
22
     * @param string         $block
23
     * @param string         $defaultValue
24
     * @return array|string
25
     */
26
    public function __invoke(ViewController $view, string $block, string $defaultValue = '')
27
    {
28
        if($view->getVariable($block) === '') {
29
            return $defaultValue;
30
        }
31
        return trim($view->getVariable($block));
32
    }
33
34
}