| Conditions | 4 |
| Paths | 7 |
| Total Lines | 20 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4.0058 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 6 | 36 | public function render(View $view, string $template, array $params): string |
|
| 7 | { |
||
| 8 | $renderer = function () use ($template, $params) { |
||
| 9 | 36 | extract($params, EXTR_OVERWRITE); |
|
| 10 | 36 | require $template; |
|
| 11 | 36 | }; |
|
| 12 | |||
| 13 | 36 | $obInitialLevel = ob_get_level(); |
|
| 14 | 36 | ob_start(); |
|
| 15 | 36 | ob_implicit_flush(0); |
|
| 16 | try { |
||
| 17 | 36 | $renderer->bindTo($view)(); |
|
| 18 | 36 | return ob_get_clean(); |
|
| 19 | 1 | } catch (\Throwable $e) { |
|
| 20 | 1 | while (ob_get_level() > $obInitialLevel) { |
|
| 21 | 1 | if (!@ob_end_clean()) { |
|
| 22 | ob_clean(); |
||
| 23 | } |
||
| 24 | } |
||
| 25 | 1 | throw $e; |
|
| 26 | } |
||
| 29 |