Passed
Push — master ( bb8381...e42fb8 )
by Edson
02:29
created

Tpl::setDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace EdsonOnildo\Tpl;
4
5
class Tpl
6
{
7
    private static $assign = [];
8
    private static $engine = null;
9
10
    private static $dev = false;
11
    private static $dir = 'view/';
12
    private static $url = 'http://localhost/';
13
14
    private static function engine(): Engine
15
    {
16
        if (!isset(self::$engine) || is_null(self::$engine)) {
17
            self::$engine = new Engine;
18
        }
19
        return self::$engine;
20
    }
21
22
    public static function setDev(bool $dev): void
23
    {
24
        self::$dev = $dev;
25
    }
26
27
    public static function setDir(String $dir): void
28
    {
29
        self::$dir = $dir;
30
    }
31
32
    public static function getDir(): String
33
    {
34
        return self::$dir;
35
    }
36
37
    public static function setUrl(String $url): void
38
    {
39
        self::$url = $url;
40
    }
41
42
    public static function getUrl(): String
43
    {
44
        return self::$url;
45
    }
46
47
    public static function config(array $config): void
48
    {
49
        self::engine()->config($config);
0 ignored issues
show
Bug introduced by
The method config() does not exist on EdsonOnildo\Tpl\Engine. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        self::engine()->/** @scrutinizer ignore-call */ config($config);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
    }
51
52
    public static function assign(string $key, $value): void
53
    {
54
        if (is_array($value)) {
55
            $value = json_decode(json_encode($value), false);
56
        }
57
        self::$assign[$key] = $value;
58
    }
59
60
    public static function render(string $template): void
61
    {
62
        echo self::engine()->render($template, self::$assign);
63
    }
64
}
65