Completed
Pull Request — master (#4)
by James Ekow Abaka
03:06 queued 36s
created

Core::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace ntentan\honam\engines\smarty;
3
4
use ntentan\utils\Filesystem;
5
use Smarty;
6
7
class Core extends Smarty
8
{
9
    private $temp = '.';
10
11 1
    public function __construct(string $tempDirectory)
12
    {
13 1
        parent::__construct();
14 1
        $this->temp = $tempDirectory;
15 1
        $this->setCompileDir("{$this->temp}/smarty_compiled_templates");
16 1
    }
17
    
18
    public function __destruct() 
19
    {
20
        if($this->temp === '.' && file_exists("./smarty_compiled_templates")) {
21
            Filesystem::get("./smarty_compiled_templates")->delete();
22
        }
23
    }
24
25 1
    public function setData($data)
26
    {
27 1
        $this->clearAllAssign();
28 1
        $this->assign($data);
29 1
    }
30
}
31