Completed
Push — master ( 8d3e79...9daf84 )
by Edson
04:12
created

Tpl::engine()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

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