Conditions | 4 |
Paths | 5 |
Total Lines | 31 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
11 | public function render(string $view, array $data = []): string |
||
12 | { |
||
13 | try { |
||
14 | $content = $this->handle(Content::getContent($view)); |
||
15 | } catch (Exception $e) { // @codeCoverageIgnore |
||
|
|||
16 | return $e->getMessage(); // @codeCoverageIgnore |
||
17 | } |
||
18 | |||
19 | $this->data = array_merge($this->data, $data); |
||
20 | |||
21 | if (!array_key_exists('page', $this->data)) { |
||
22 | $this->data['page'] = $_SERVER['REQUEST_URI']; |
||
23 | } |
||
24 | |||
25 | $dir = Tpl::getDir() . '.cache/'; |
||
26 | |||
27 | if (!is_dir($dir)) { |
||
28 | mkdir($dir); |
||
29 | } |
||
30 | |||
31 | $fname = $dir . md5($view) . '.phtml'; |
||
32 | |||
33 | $file = new File($fname); |
||
34 | |||
35 | $this->setCache($file, $content); |
||
36 | |||
37 | $content = $file->read($this->data); |
||
38 | |||
39 | $file->close(); |
||
40 | |||
41 | return trim($content); |
||
42 | } |
||
77 |