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

ParseTpl::getContent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 4
cts 5
cp 0.8
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2.032
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 2
    public function config(array $config)
11
    {
12 2
        $this->config = $config;
13 2
    }
14
15 4
    public function getContent($view): string
16
    {
17 4
        $file = getcwd() . '/' . $this->config['template_dir'] . "/$view.html";
18
19 4
        if (!file_exists($file)) {
20
            throw new \Exception("$file template not found");
21
        }
22
23 4
        return $this->removeTags(file_get_contents($file));
24
    }
25
26 4
    public function removeTags($content)
27
    {
28 4
        return str_replace(array("<?", "?>"), array("&lt;?", "?&gt;"), $content);
29
    }
30
}
31