Conditions | 1 |
Paths | 1 |
Total Lines | 24 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 21 |
CRAP Score | 1 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | 1 | public function compile(Compiler $compiler): void |
|
34 | { |
||
35 | 1 | $runtimeErrorClass = RuntimeError::class; |
|
36 | 1 | $suppressedExceptionClass = SuppressedException::class; |
|
37 | |||
38 | $compiler |
||
39 | 1 | ->write("try {\n") |
|
40 | 1 | ->indent() |
|
41 | 1 | ->write("ob_start();\n\n") |
|
42 | 1 | ->subcompile($this->getNode('body')) |
|
43 | 1 | ->raw("\n") |
|
44 | 1 | ->write("echo ob_get_clean();\n") |
|
45 | 1 | ->outdent() |
|
46 | 1 | ->write("} catch ({$runtimeErrorClass} \$exception) {\n") |
|
47 | 1 | ->indent() |
|
48 | 1 | ->write("ob_end_clean();\n\n") |
|
49 | 1 | ->write("if (\$exception->getPrevious() === null) {\n") |
|
50 | 1 | ->indent() |
|
51 | 1 | ->write("throw \$exception;\n") |
|
52 | 1 | ->outdent() |
|
53 | 1 | ->write("}\n\n") |
|
54 | 1 | ->write("\$suppressedException = new {$suppressedExceptionClass}(\$exception->getPrevious());\n") |
|
55 | 1 | ->outdent() |
|
56 | 1 | ->write("}\n\n"); |
|
57 | 1 | } |
|
59 |