Completed
Push — master ( d05011...b5c800 )
by Edson
01:28
created

Tpl::render()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 19
cts 19
cp 1
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 18
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Bonfim\Component\View;
4
5
class Tpl
6
{
7
    use ParseTpl;
8
9 2
    public function render(string $view, array $data = []) : string
10
    {
11 2
        $content = $this->getContent($view);
12 2
        $content = new Inheritance($content, $this->config);
13 2
        $content = new IncludeTpl($content, $this->config);
14 2
        $content = new ForeachTpl($content);
15 2
        $content = new IfTpl($content);
16 2
        $content = new FuncTpl($content);
17 2
        $content = new VariableTpl($content);
18
19
20 2
        $this->data = array_merge($data, $this->data);
21 2
        extract($this->data);
22 2
        $tmp = tmpfile();
23
24 2
        fwrite($tmp, $content);
0 ignored issues
show
Bug introduced by
It seems like $tmp can also be of type false; however, parameter $handle of fwrite() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

24
        fwrite(/** @scrutinizer ignore-type */ $tmp, $content);
Loading history...
25 2
        fseek($tmp, 0);
0 ignored issues
show
Bug introduced by
It seems like $tmp can also be of type false; however, parameter $handle of fseek() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

25
        fseek(/** @scrutinizer ignore-type */ $tmp, 0);
Loading history...
26
27 2
        ob_start();
28 2
        $file = stream_get_meta_data($tmp);
0 ignored issues
show
Bug introduced by
It seems like $tmp can also be of type false; however, parameter $stream of stream_get_meta_data() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

28
        $file = stream_get_meta_data(/** @scrutinizer ignore-type */ $tmp);
Loading history...
29
30 2
        include $file['uri'];
31 2
        $content = ob_get_clean();
32 2
        fclose($tmp);
0 ignored issues
show
Bug introduced by
It seems like $tmp can also be of type false; however, parameter $handle of fclose() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

32
        fclose(/** @scrutinizer ignore-type */ $tmp);
Loading history...
33 2
        return $content;
34
    }
35
}
36