Conditions | 4 |
Paths | 10 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
22 | 52 | public function render(BaseView $view, string $template, array $params): string |
|
23 | { |
||
24 | 52 | $renderer = function (): void { |
|
25 | /** @psalm-suppress MixedArgument */ |
||
26 | 52 | extract(func_get_arg(1), EXTR_OVERWRITE); |
|
27 | /** @psalm-suppress UnresolvableInclude */ |
||
28 | 52 | require func_get_arg(0); |
|
29 | 52 | }; |
|
30 | |||
31 | 52 | $obInitialLevel = ob_get_level(); |
|
32 | 52 | ob_start(); |
|
33 | /** @psalm-suppress PossiblyFalseArgument */ |
||
34 | 52 | PHP_VERSION_ID >= 80000 ? ob_implicit_flush(false) : ob_implicit_flush(0); |
|
35 | try { |
||
36 | /** @psalm-suppress PossiblyInvalidFunctionCall */ |
||
37 | 52 | $renderer->bindTo($view)($template, $params); |
|
38 | 51 | return ob_get_clean(); |
|
39 | 2 | } catch (Throwable $e) { |
|
40 | 2 | while (ob_get_level() > $obInitialLevel) { |
|
41 | 2 | ob_end_clean(); |
|
42 | } |
||
43 | 2 | throw $e; |
|
44 | } |
||
47 |