Passed
Push — master ( b647e5...e2d0b4 )
by Edson
01:29
created

Tpl::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sketch;
4
5
use Sketch\Tpl\Engine;
6
7
class Tpl
8
{
9
    private static $assign = [];
10
    private static $engine = null;
11
12
    /**
13
     * @return Engine
14
     */
15 2
    private static function engine(): Engine
16
    {
17 2
        if (!isset(self::$engine) || is_null(self::$engine)) {
18 2
            self::$engine = new Engine;
19
        }
20
21 2
        return self::$engine;
22
    }
23
24
    /**
25
     * @param array $config
26
     */
27 2
    public static function config(array $config): void
28
    {
29 2
        self::engine()->config($config);
30 2
    }
31
32
    /**
33
     * @param string $key
34
     * @param $value
35
     */
36 2
    public static function assign(string $key, $value): void
37
    {
38 2
        self::$assign[$key] = $value;
39 2
    }
40
41
    /**
42
     * @param string $template
43
     * @return string
44
     */
45 2
    public static function render(string $template): string
46
    {
47 2
        return self::engine()->render($template, self::$assign);
48
    }
49
}
50