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

ParseTpl   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 6
cts 9
cp 0.6667
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A removeTags() 0 3 1
A config() 0 3 1
A getContent() 0 9 2
1
<?php
2
3
namespace Bonfim\Component\View;
4
5
trait ParseTpl
6
{
7
    protected $config;
8
    protected $data = ['__version' => '1.0.0'];
9
10
    public function config(array $config)
11
    {
12
        $this->config = $config;
13
    }
14
15 2
    public function getContent($view): string
16
    {
17 2
        $file = getcwd() . '/' . $this->config['template_dir'] . "/$view.html";
18
19 2
        if (!file_exists($file)) {
20
            throw new \Exception("$file template not found"); // @codeCoverageIgnore
21
        }
22
23 2
        return $this->removeTags(file_get_contents($file));
24
    }
25
26 2
    public function removeTags($content)
27
    {
28 2
        return str_replace(array("<?", "?>"), array("&lt;?", "?&gt;"), $content);
29
    }
30
}
31