Passed
Push — master ( ab7df5...238a89 )
by Edson
01:47
created

ParseTpl   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 27
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

3 Methods

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