From 58a68da32a0295077a45baf1e0629f4413c49cf3 Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Mon, 31 Mar 2025 20:53:49 +0300 Subject: [PATCH] The text description of the statuses is moved to `StatusEnum` --- src/Enums/StatusEnum.php | 21 +++++++++++++++++++++ src/Processors/StatusProcessor.php | 9 +++------ src/Services/MigratorService.php | 5 +++-- 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 src/Enums/StatusEnum.php diff --git a/src/Enums/StatusEnum.php b/src/Enums/StatusEnum.php new file mode 100644 index 00000000..a170e581 --- /dev/null +++ b/src/Enums/StatusEnum.php @@ -0,0 +1,21 @@ + 'Ran', + self::Pending => 'Pending', + self::Skipped => 'Skipped', + }; + } +} diff --git a/src/Processors/StatusProcessor.php b/src/Processors/StatusProcessor.php index b09ce71c..3eed14db 100644 --- a/src/Processors/StatusProcessor.php +++ b/src/Processors/StatusProcessor.php @@ -4,6 +4,7 @@ namespace DragonCode\LaravelDeployOperations\Processors; +use DragonCode\LaravelDeployOperations\Enums\StatusEnum; use DragonCode\Support\Facades\Helpers\Arr; use function sprintf; @@ -14,10 +15,6 @@ class StatusProcessor extends Processor protected string $columnStatus = 'Batch / Status'; - protected string $statusRan = 'Ran'; - - protected string $statusPending = 'Pending'; - public function handle(): void { if ($this->tableNotFound()) { @@ -72,10 +69,10 @@ protected function getData(): array protected function getStatusFor(array $completed, string $item): string { if ($batch = Arr::get($completed, $item)) { - return sprintf('[%s] %s', $batch, $this->statusRan); + return sprintf('[%s] %s', $batch, StatusEnum::Ran->toColor()); } - return $this->statusPending; + return StatusEnum::Pending->toColor(); } protected function getCompleted(): array diff --git a/src/Services/MigratorService.php b/src/Services/MigratorService.php index b570eea8..41f0ba46 100644 --- a/src/Services/MigratorService.php +++ b/src/Services/MigratorService.php @@ -5,6 +5,7 @@ namespace DragonCode\LaravelDeployOperations\Services; use DragonCode\LaravelDeployOperations\Data\OptionsData; +use DragonCode\LaravelDeployOperations\Enums\StatusEnum; use DragonCode\LaravelDeployOperations\Helpers\ConfigHelper; use DragonCode\LaravelDeployOperations\Jobs\OperationJob; use DragonCode\LaravelDeployOperations\Notifications\Notification; @@ -52,7 +53,7 @@ public function runUp(string $filename, int $batch, OptionsData $options): void $name = $this->resolveOperationName($path); if (! $this->allowOperation($operation, $options)) { - $this->notification->twoColumn($name, 'SKIPPED'); + $this->notification->twoColumn($name, StatusEnum::Skipped->toColor()); return; } @@ -60,7 +61,7 @@ public function runUp(string $filename, int $batch, OptionsData $options): void if ($this->hasAsync($operation, $options)) { OperationJob::dispatch($name); - $this->notification->twoColumn($name, 'PENDING'); + $this->notification->twoColumn($name, StatusEnum::Pending->toColor()); return; }