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

Tpl   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A assign() 0 3 1
A render() 0 3 1
A config() 0 3 1
A engine() 0 7 3
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