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

Core   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 73.32%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 27
ccs 11
cts 15
cp 0.7332
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A __destruct() 0 6 3
A setData() 0 6 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