Passed
Push — master ( 71f7aa...5a3352 )
by Edson
01:34
created

Tpl::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 2
dl 0
loc 21
ccs 0
cts 14
cp 0
crap 6
rs 9.3142
c 0
b 0
f 0
1
<?php
2
3
namespace Bonfim\Component\View;
4
5
class Tpl
6
{
7
    use ParseTpl;
8
9
    public function render(string $view, array $data = []) : string
10
    {
11
        $content = $this->getContent();
12
13
        $this->data = array_merge($data, $this->data);
14
        extract($this->data);
15
16
        $tmp = tmpfile();
17
18
        if ($tmp !== false) {
19
            fwrite($tmp, $content);
20
            fseek($tmp, 0);
21
22
            ob_start();
23
            $file = stream_get_meta_data($tmp);
24
25
            include $file['uri'];
26
            $content = ob_get_clean();
27
            fclose($tmp);
28
        }
29
        return $content;
30
    }
31
32
    private function getContent()
33
    {
34
        $content = $this->getContent($view);
0 ignored issues
show
Unused Code introduced by
The call to Bonfim\Component\View\Tpl::getContent() has too many arguments starting with $view. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        /** @scrutinizer ignore-call */ 
35
        $content = $this->getContent($view);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Comprehensibility Best Practice introduced by
The variable $view seems to be never defined.
Loading history...
35
        $content = new Inheritance($content, $this->config);
36
        $content = new IncludeTpl($content, $this->config);
37
        $content = new ForeachTpl($content);
38
        $content = new IfTpl($content);
39
        $content = new FuncTpl($content);
40
        $content = new VariableTpl($content);
41
42
        return $content;
43
    }
44
}
45