Test Failed
Push — master ( e3ba09...03f0a0 )
by Flo
02:41
created

Block::__invoke()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 1
1
<?php
2
3
namespace Faulancer\View\Helper;
4
5
use Faulancer\View\AbstractViewHelper;
6
7
/**
8
 * Class Block
9
 *
10
 * @package Faulancer\View\Helper
11
 * @author  Florian Knapp <[email protected]>
12
 */
13
class Block extends AbstractViewHelper
14
{
15
16
    /** @var bool */
17
    protected static $tagOpened = false;
18
    protected static $content   = '';
19
20
    /**
21
     * Block opening handler
22
     *
23
     * @param string $name
24
     */
25
    public function __invoke(string $name = '')
26
    {
27
        if (!self::$tagOpened) {
28
29
            ob_start(function($buffer) {
30
                self::$content = $buffer;
31
            });
32
33
        } else {
34
35
            $content = ob_get_contents();
36
            ob_end_clean();
37
38
            $this->view->getParentTemplate()->setVariable($name, $content);
39
40
            //unset($this->blockName);
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
            //unset($this->blockContent);
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
42
43
            self::$tagOpened = false;
44
45
        }
46
47
        self::$tagOpened = true;
48
    }
49
50
    public function __destruct()
51
    {
52
        self::$tagOpened = false;
53
    }
54
55
}