Completed
Push — dev ( 26974b...a486ee )
by James Ekow Abaka
01:47
created

Core::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

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