Skip to content

Commit ededc90

Browse files
committed
remove code duplication
1 parent eae6010 commit ededc90

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

system/Debug/ExceptionHandler.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ public function handle(
7676
}
7777

7878
if (! str_contains($request->getHeaderLine('accept'), 'text/html')) {
79-
$data = in_array(
80-
strtolower(ini_get('display_errors')),
81-
['1', 'true', 'on', 'yes'],
82-
true
83-
)
79+
$data = $this->isDisplayErrorsEnabled()
8480
? $this->collectVars($exception, $statusCode)
8581
: '';
8682

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

141-
if (
142-
in_array(
143-
strtolower(ini_get('display_errors')),
144-
['1', 'true', 'on', 'yes'],
145-
true
146-
)
147-
) {
137+
if ($this->isDisplayErrorsEnabled()) {
148138
$view = 'error_exception.php';
149139
}
150140

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

163153
return $view;
164154
}
155+
156+
/**
157+
* Whether the PHP display_errors setting is enabled.
158+
*/
159+
private function isDisplayErrorsEnabled(): bool
160+
{
161+
return in_array(
162+
strtolower(ini_get('display_errors')),
163+
['1', 'true', 'on', 'yes'],
164+
true
165+
);
166+
}
165167
}

0 commit comments

Comments
 (0)