Conditions | 3 |
Paths | 5 |
Total Lines | 21 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
29 | 2 | public function render(Template $template): string |
|
30 | { |
||
31 | 2 | $view = $template->getView(); |
|
32 | 2 | $templateFile = str_replace( |
|
33 | 2 | [$view->getBasePath(), $template->getViewContext()?->getViewPath() ?? ''], |
|
34 | 2 | '', |
|
35 | 2 | $template->getTemplate() |
|
36 | 2 | ); |
|
37 | |||
38 | 2 | $obInitialLevel = ob_get_level(); |
|
39 | 2 | ob_start(); |
|
40 | 2 | ob_implicit_flush(false); |
|
41 | |||
42 | try { |
||
43 | 2 | $this->environment->display($templateFile, array_merge($template->getParameters(), ['this' => $view])); |
|
44 | 1 | return ob_get_clean(); |
|
45 | 1 | } catch (Throwable $e) { |
|
46 | 1 | while (ob_get_level() > $obInitialLevel) { |
|
47 | 1 | ob_end_clean(); |
|
48 | } |
||
49 | 1 | throw $e; |
|
50 | } |
||
53 |