Total Complexity | 4 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
5 | class Engine extends Content |
||
6 | { |
||
7 | private $config; |
||
8 | private $data = ['__version' => '1.1.0']; |
||
9 | |||
10 | 2 | public function config(array $config): void |
|
13 | 2 | } |
|
14 | |||
15 | 2 | public function render(string $view, array $data = []): string |
|
16 | { |
||
17 | 2 | $content = $this->handle($this->getContent($view, $this->config)); |
|
18 | |||
19 | 2 | $this->data = array_merge($data, $this->data); |
|
20 | |||
21 | 2 | $fname = getcwd() . '/' . $this->config['cache_dir'] . '/' . $view . '.phtml'; |
|
22 | |||
23 | 2 | $file = new File; |
|
24 | |||
25 | 2 | if ($file->create($fname) !== false) { |
|
26 | 2 | $file->write($content); |
|
27 | 2 | $content = $file->read($this->data); |
|
28 | 2 | $file->close(); |
|
29 | } |
||
30 | |||
31 | 2 | return $content; |
|
32 | } |
||
33 | |||
34 | 2 | private function handle($content) |
|
44 | } |
||
45 | } |
||
46 |