Completed
Push — master ( 8d3e79...9daf84 )
by Edson
04:12
created

Content::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

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 9
ccs 4
cts 4
cp 1
crap 2
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Bonfim\Tpl;
4
5
class Content
6
{
7 4
    public function getContent(string $view, array $config): string
8
    {
9 4
        $file = getcwd() . '/' . $config['template_dir'] . "/$view.html";
10
11 4
        if (!file_exists($file)) {
12
            throw new \Exception("$file template not found"); // @codeCoverageIgnore
13
        }
14
15 4
        return $this->removeTags(file_get_contents($file));
16
    }
17
18 4
    public function removeTags($content)
19
    {
20 4
        return str_replace(array("<?", "?>"), array("&lt;?", "?&gt;"), $content);
21
    }
22
}
23