Completed
Push — master ( c49986...8dc409 )
by Edson
01:16
created

Tpl::assign()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
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
    private static function engine(): Engine
13
    {
14
        if (!isset(self::$engine) || is_null(self::$engine)) {
15
            self::$engine = new Engine;
16
        }
17
18
        return self::$engine;
19
    }
20
21
    public static function config(array $config): void
22
    {
23
        self::engine()->config($config);
24
    }
25
26
    public static function assign(string $key, $value): void
27
    {
28
        self::$assign[$key] = $value;
29
    }
30
31
    public static function render(string $template): string
32
    {
33
        return self::engine()->render($template, self::$assign);
34
    }
35
}
36