| Total Complexity | 4 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 90.91% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class DefaultExceptionHandler implements ExceptionHandlerInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var ExceptionPrinterInterface |
||
| 14 | */ |
||
| 15 | private $printer; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var bool |
||
| 19 | */ |
||
| 20 | private $shutdownIfError; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * DefaultExceptionHandler constructor. |
||
| 24 | * |
||
| 25 | * @param ExceptionPrinterInterface $printer |
||
| 26 | * @param bool $shutdownIfError |
||
| 27 | */ |
||
| 28 | 1 | public function __construct( |
|
| 29 | ExceptionPrinterInterface $printer, |
||
| 30 | bool $shutdownIfError |
||
| 31 | ) { |
||
| 32 | 1 | $this->printer = $printer; |
|
| 33 | 1 | $this->shutdownIfError = $shutdownIfError; |
|
| 34 | 1 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * @param \Exception $exception |
||
| 38 | */ |
||
| 39 | 1 | public function handleException(\Exception $exception): void |
|
| 40 | { |
||
| 41 | 1 | $this->printer->printExeption($exception); |
|
| 42 | 1 | $this->shutdownXervicelication(); |
|
| 43 | 1 | } |
|
| 44 | |||
| 45 | 1 | protected function shutdownXervicelication(): void |
|
| 49 | } |
||
| 50 | } |
||
| 51 | } |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.