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

Tpl::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 2
dl 0
loc 21
ccs 14
cts 14
cp 1
crap 2
rs 9.3142
c 0
b 0
f 0

3 Methods

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