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

RenderBlock   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 2
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
}