Skip to content

Commit

Permalink
remove code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsn committed Dec 9, 2024
1 parent eae6010 commit ededc90
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions system/Debug/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ public function handle(
}

if (! str_contains($request->getHeaderLine('accept'), 'text/html')) {
$data = in_array(
strtolower(ini_get('display_errors')),
['1', 'true', 'on', 'yes'],
true
)
$data = $this->isDisplayErrorsEnabled()
? $this->collectVars($exception, $statusCode)
: '';

Expand Down Expand Up @@ -138,13 +134,7 @@ protected function determineView(
// Production environments should have a custom exception file.
$view = 'production.php';

if (
in_array(
strtolower(ini_get('display_errors')),
['1', 'true', 'on', 'yes'],
true
)
) {
if ($this->isDisplayErrorsEnabled()) {
$view = 'error_exception.php';
}

Expand All @@ -162,4 +152,16 @@ protected function determineView(

return $view;
}

/**
* Whether the PHP display_errors setting is enabled.
*/
private function isDisplayErrorsEnabled(): bool
{
return in_array(
strtolower(ini_get('display_errors')),
['1', 'true', 'on', 'yes'],
true
);
}
}

0 comments on commit ededc90

Please sign in to comment.