Completed
Push — master ( 5a3352...e7f541 )
by Edson
01:28
created

Tpl   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 21 2
A handle() 0 10 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->handle($this->getContent($view));
12
13 2
        $this->data = array_merge($data, $this->data);
14 2
        extract($this->data);
15
16 2
        $tmp = tmpfile();
17
18 2
        if ($tmp !== false) {
19 2
            fwrite($tmp, $content);
20 2
            fseek($tmp, 0);
21
22 2
            ob_start();
23 2
            $file = stream_get_meta_data($tmp);
24
25 2
            include $file['uri'];
26 2
            $content = ob_get_clean();
27 2
            fclose($tmp);
28
        }
29 2
        return $content;
30
    }
31
32 2
    private function handle($content)
33
    {
34 2
        $content = new Inheritance($content, $this->config);
35 2
        $content = new IncludeTpl($content, $this->config);
36 2
        $content = new ForeachTpl($content);
37 2
        $content = new IfTpl($content);
38 2
        $content = new FuncTpl($content);
39 2
        $content = new VariableTpl($content);
40
41 2
        return $content;
42
    }
43
}
44