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

ParseTpl::match()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 2
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