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