Skip to content

Commit

Permalink
refactor(src): Improve extendExceptionHandler method in ExceptionNoti…
Browse files Browse the repository at this point in the history
…fyServiceProvider

  - Simplified conditional logic in the extendExceptionHandler method
  - Removed unnecessary method_exists check
  • Loading branch information
guanguans committed Mar 31, 2024
1 parent 6841cf3 commit dd2432b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/ExceptionNotifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Illuminate\Container\Container;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Foundation\Exceptions\Handler;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
Expand Down Expand Up @@ -142,10 +143,7 @@ protected function registerTestCommand(): self
protected function extendExceptionHandler(): self
{
$this->app->extend(ExceptionHandler::class, function (ExceptionHandler $exceptionHandler): ExceptionHandler {
if (
($reportUsingCreator = config('exception-notify.report_using_creator'))
&& method_exists($exceptionHandler, 'reportable')
) {
if ($reportUsingCreator = config('exception-notify.report_using_creator')) {
/** @var callable(ExceptionHandler):callable|class-string $reportUsingCreator */
if (\is_string($reportUsingCreator) && class_exists($reportUsingCreator)) {
$reportUsingCreator = $this->app->make($reportUsingCreator);
Expand All @@ -157,6 +155,7 @@ protected function extendExceptionHandler(): self
$reportUsing = $reportUsing->bindTo($exceptionHandler, $exceptionHandler);
}

/** @var Handler $exceptionHandler */
$exceptionHandler->reportable($reportUsing);
}

Expand Down

0 comments on commit dd2432b

Please sign in to comment.