| Total Complexity | 5 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Core |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @param callable $callback |
||
| 12 | * @param callable $handler |
||
| 13 | * @param int $types |
||
| 14 | * @return mixed |
||
| 15 | * @throws \Exception|\Throwable |
||
| 16 | */ |
||
| 17 | public static function handle($callback, $handler, $types = null) |
||
| 18 | 20 | { |
|
| 19 | \set_error_handler($handler, $types === null ? \E_ALL | \E_STRICT : $types); |
||
| 20 | 20 | ||
| 21 | try { |
||
| 22 | $result = \call_user_func($callback); |
||
| 23 | 20 | \restore_error_handler(); |
|
| 24 | 7 | return $result; |
|
| 25 | 7 | } catch (\Exception $e) { |
|
|
|
|||
| 26 | 13 | } catch (\Throwable $e) { |
|
| 27 | 5 | } |
|
| 28 | |||
| 29 | \restore_error_handler(); |
||
| 30 | 13 | throw $e; |
|
| 31 | 13 | } |
|
| 32 | |||
| 33 | /** |
||
| 34 | * @param \Exception|\Throwable $e |
||
| 35 | * @param string $file |
||
| 36 | * @param int $line |
||
| 37 | * @return \Exception|\Throwable $e |
||
| 38 | */ |
||
| 39 | public static function rewriteLocation($e, $file, $line) |
||
| 53 | 8 | } |
|
| 54 | } |
||
| 55 |