| Conditions | 5 |
| Paths | 14 |
| Total Lines | 20 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5.9256 |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | 1 | public function render(View $view, string $template, array $parameters): string |
|
| 12 | { |
||
| 13 | 1 | $renderer = function () { |
|
| 14 | 1 | extract(func_get_arg(1), EXTR_OVERWRITE); |
|
| 15 | 1 | eval(func_get_arg(0)); |
|
|
|
|||
| 16 | 1 | }; |
|
| 17 | |||
| 18 | 1 | $obInitialLevel = ob_get_level(); |
|
| 19 | 1 | ob_start(); |
|
| 20 | 1 | PHP_VERSION_ID >= 80000 ? ob_implicit_flush(false) : ob_implicit_flush(0); |
|
| 21 | try { |
||
| 22 | 1 | $renderer->bindTo($view)($template, $parameters); |
|
| 23 | 1 | return ob_get_clean(); |
|
| 24 | } catch (\Throwable $e) { |
||
| 25 | while (ob_get_level() > $obInitialLevel) { |
||
| 26 | if (!@ob_end_clean()) { |
||
| 27 | ob_clean(); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | throw $e; |
||
| 31 | } |
||
| 34 |