From 08eba5b3adc2dece686f1382dc3c7a03d60951eb Mon Sep 17 00:00:00 2001 From: freekmurze Date: Wed, 30 Aug 2023 14:16:51 +0000 Subject: [PATCH] Fix styling --- src/Commands/BackupCommand.php | 3 ++- src/Exceptions/BackupFailed.php | 6 ++++-- tests/Notifications/EventHandlerTest.php | 1 - 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Commands/BackupCommand.php b/src/Commands/BackupCommand.php index 18f35b2a..126bdd83 100644 --- a/src/Commands/BackupCommand.php +++ b/src/Commands/BackupCommand.php @@ -82,7 +82,8 @@ public function handle(): int report($exception); if (! $disableNotifications) { - event($exception instanceof BackupFailed + event( + $exception instanceof BackupFailed ? new BackupHasFailed($exception->getPrevious(), $exception->backupDestination) : new BackupHasFailed($exception) ); diff --git a/src/Exceptions/BackupFailed.php b/src/Exceptions/BackupFailed.php index e8b13c42..3670c302 100644 --- a/src/Exceptions/BackupFailed.php +++ b/src/Exceptions/BackupFailed.php @@ -12,11 +12,13 @@ class BackupFailed extends Exception { public ?BackupDestination $backupDestination = null; - public static function from(Exception $exception): static { + public static function from(Exception $exception): static + { return new static($exception->getMessage(), $exception->getCode(), $exception); } - public function destination(BackupDestination $backupDestination): static { + public function destination(BackupDestination $backupDestination): static + { $this->backupDestination = $backupDestination; return $this; diff --git a/tests/Notifications/EventHandlerTest.php b/tests/Notifications/EventHandlerTest.php index d7c59753..a5ce83de 100644 --- a/tests/Notifications/EventHandlerTest.php +++ b/tests/Notifications/EventHandlerTest.php @@ -3,7 +3,6 @@ use Illuminate\Support\Facades\Notification; use Spatie\Backup\BackupDestination\BackupDestinationFactory; use Spatie\Backup\Events\BackupHasFailed; -use Spatie\Backup\Exceptions\BackupFailed; use Spatie\Backup\Notifications\Notifiable; use Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification as BackupHasFailedNotification;