Conditions | 5 |
Paths | 9 |
Total Lines | 26 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
37 | public function render($template, array $data = []) |
||
38 | { |
||
39 | if (isset($data['template'])) { |
||
40 | throw new \InvalidArgumentException('Duplicate template key found'); |
||
41 | } |
||
42 | |||
43 | if (!is_file($this->templatePath . $template)) { |
||
44 | throw new \RuntimeException('View cannot render `$template` because the template does not exist'); |
||
45 | } |
||
46 | |||
47 | $data = array_merge($this->attributes, $data); |
||
48 | |||
49 | try { |
||
50 | ob_start(); |
||
51 | $this->protectedIncludeScope($this->templatePath . $template, $data); |
||
52 | $output = ob_get_clean(); |
||
53 | } catch(\Throwable $e) { // PHP 7+ |
||
54 | ob_end_clean(); |
||
55 | throw $e; |
||
56 | } catch(\Exception $e) { // PHP < 7 |
||
57 | ob_end_clean(); |
||
58 | throw $e; |
||
59 | } |
||
60 | |||
61 | return $output; |
||
62 | } |
||
63 | |||
74 |