From ededc90c0fda245ae4737fe6ada8d92a8497ee1e Mon Sep 17 00:00:00 2001 From: michalsn Date: Mon, 9 Dec 2024 08:43:09 +0100 Subject: [PATCH] remove code duplication --- system/Debug/ExceptionHandler.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/system/Debug/ExceptionHandler.php b/system/Debug/ExceptionHandler.php index 41b67a626f37..8d495402a23d 100644 --- a/system/Debug/ExceptionHandler.php +++ b/system/Debug/ExceptionHandler.php @@ -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) : ''; @@ -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'; } @@ -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 + ); + } }