Completed
Push — master ( 02b122...2a8558 )
by James Ekow Abaka
02:43
created

Engine   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
B __destruct() 0 16 5
1
<?php
2
namespace ntentan\honam\template_engines\smarty;
3
4
use ntentan\honam\TemplateEngine;
5
6
class Engine extends \Smarty
7
{
8
    private $temp;
9
    
10 2
    public function __construct() 
11
    {
12 2
        parent::__construct();
13 2
        $this->temp = TemplateEngine::getTempDirectory();
14 2
        $this->setCompileDir("{$this->temp}/smarty_compiled_templates");
15 2
    }
16
    
17 1
    public function __destruct() 
18
    {
19 1
        if($this->temp === '.' && file_exists("./smarty_compiled_templates"))
20
        {
21 1
            $files = scandir("./smarty_compiled_templates");
22 1
            foreach($files as $file)
23
            {
24 1
                if($file == "." | $file == "..")
0 ignored issues
show
Comprehensibility introduced by
Consider adding parentheses for clarity. Current Interpretation: ($file == '.') | $file == '..', Probably Intended Meaning: $file == ('.' | $file == '..')

When comparing the result of a bit operation, we suggest to add explicit parenthesis and not to rely on PHP’s built-in operator precedence to ensure the code behaves as intended and to make it more readable.

Let’s take a look at these examples:

// Returns always int(0).
return 0 === $foo & 4;
return (0 === $foo) & 4;

// More likely intended return: true/false
return 0 === ($foo & 4);
Loading history...
25
                {
26 1
                    continue;
27
                }
28 1
                unlink("./smarty_compiled_templates/$file");
29
            }
30 1
            rmdir("./smarty_compiled_templates");
31
        }
32 1
    }
33
}
34