1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bonfim\Tpl; |
4
|
|
|
|
5
|
|
|
class Tpl |
6
|
|
|
{ |
7
|
|
|
private static $assign = []; |
8
|
|
|
private static $engine = null; |
9
|
|
|
|
10
|
|
|
private static $dev = false; |
11
|
|
|
private static $dir = 'view/'; |
12
|
|
|
private static $url = 'http://localhost/'; |
13
|
|
|
private static $assets = 'assets/'; |
14
|
|
|
|
15
|
|
|
private static function engine(): Engine |
16
|
|
|
{ |
17
|
|
|
if (!isset(self::$engine) || is_null(self::$engine)) { |
18
|
|
|
self::$engine = new Engine; |
19
|
|
|
} |
20
|
|
|
return self::$engine; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public static function setDev(bool $dev): void |
24
|
|
|
{ |
25
|
|
|
self::$dev = $dev; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public static function setDir(String $dir): void |
29
|
|
|
{ |
30
|
|
|
self::$dir = $dir; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public static function getDir(): String |
34
|
|
|
{ |
35
|
|
|
return self::$dir; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public static function setUrl(String $url): void |
39
|
|
|
{ |
40
|
|
|
self::$url = $url; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public static function getUrl(): String |
44
|
|
|
{ |
45
|
|
|
return self::$url; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public static function setAssets(String $assets) |
49
|
|
|
{ |
50
|
|
|
self::$assets = $assets; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public static function getAssets(): String |
54
|
|
|
{ |
55
|
|
|
return self::$assets; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public static function config(array $config): void |
59
|
|
|
{ |
60
|
|
|
self::engine()->config($config); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public static function assign(string $key, $value): void |
64
|
|
|
{ |
65
|
|
|
if (is_array($value)) { |
66
|
|
|
$value = json_decode(json_encode($value), false); |
67
|
|
|
} |
68
|
|
|
self::$assign[$key] = $value; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public static function render(string $template, array $values = []): void |
72
|
|
|
{ |
73
|
|
|
foreach ($values as $key => $value) { |
74
|
|
|
self::assign($key, $value); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
echo self::engine()->render($template, self::$assign); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.