| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public static function catchOutput($callback, $arguments = []) |
||
| 19 | { |
||
| 20 | $obInitialLevel = ob_get_level(); |
||
| 21 | ob_start(); |
||
| 22 | ob_implicit_flush(0); |
||
| 23 | try { |
||
| 24 | return [ |
||
| 25 | 'result' => call_user_func_array($callback, $arguments), |
||
| 26 | 'output' => ob_get_clean(), |
||
| 27 | ]; |
||
| 28 | } catch (\Exception $e) { |
||
| 29 | static::exceptionHandler($obInitialLevel); |
||
| 30 | |||
| 31 | throw $e; |
||
| 32 | } /* @noinspection PhpElementIsNotAvailableInCurrentPhpVersionInspection */ catch (\Throwable $e) { |
||
| 33 | // additional check for \Throwable introduced in PHP 7 |
||
| 34 | static::exceptionHandler($obInitialLevel); |
||
| 35 | |||
| 36 | throw $e; |
||
| 37 | } |
||
| 53 |