Skip to content

Commit 82af879

Browse files
Merge pull request #199
The text description of the statuses is moved to `StatusEnum`
2 parents 6871460 + 58a68da commit 82af879

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

src/Enums/StatusEnum.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DragonCode\LaravelDeployOperations\Enums;
6+
7+
enum StatusEnum
8+
{
9+
case Ran;
10+
case Pending;
11+
case Skipped;
12+
13+
public function toColor(): string
14+
{
15+
return match ($this) {
16+
self::Ran => '<fg=green;options=bold>Ran</>',
17+
self::Pending => '<fg=blue;options=bold>Pending</>',
18+
self::Skipped => '<fg=yellow;options=bold>Skipped</>',
19+
};
20+
}
21+
}

src/Processors/StatusProcessor.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace DragonCode\LaravelDeployOperations\Processors;
66

7+
use DragonCode\LaravelDeployOperations\Enums\StatusEnum;
78
use DragonCode\Support\Facades\Helpers\Arr;
89

910
use function sprintf;
@@ -14,10 +15,6 @@ class StatusProcessor extends Processor
1415

1516
protected string $columnStatus = '<fg=gray>Batch / Status</>';
1617

17-
protected string $statusRan = '<fg=green;options=bold>Ran</>';
18-
19-
protected string $statusPending = '<fg=yellow;options=bold>Pending</>';
20-
2118
public function handle(): void
2219
{
2320
if ($this->tableNotFound()) {
@@ -72,10 +69,10 @@ protected function getData(): array
7269
protected function getStatusFor(array $completed, string $item): string
7370
{
7471
if ($batch = Arr::get($completed, $item)) {
75-
return sprintf('[%s] %s', $batch, $this->statusRan);
72+
return sprintf('[%s] %s', $batch, StatusEnum::Ran->toColor());
7673
}
7774

78-
return $this->statusPending;
75+
return StatusEnum::Pending->toColor();
7976
}
8077

8178
protected function getCompleted(): array

src/Services/MigratorService.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace DragonCode\LaravelDeployOperations\Services;
66

77
use DragonCode\LaravelDeployOperations\Data\OptionsData;
8+
use DragonCode\LaravelDeployOperations\Enums\StatusEnum;
89
use DragonCode\LaravelDeployOperations\Helpers\ConfigHelper;
910
use DragonCode\LaravelDeployOperations\Jobs\OperationJob;
1011
use DragonCode\LaravelDeployOperations\Notifications\Notification;
@@ -52,15 +53,15 @@ public function runUp(string $filename, int $batch, OptionsData $options): void
5253
$name = $this->resolveOperationName($path);
5354

5455
if (! $this->allowOperation($operation, $options)) {
55-
$this->notification->twoColumn($name, '<fg=yellow;options=bold>SKIPPED</>');
56+
$this->notification->twoColumn($name, StatusEnum::Skipped->toColor());
5657

5758
return;
5859
}
5960

6061
if ($this->hasAsync($operation, $options)) {
6162
OperationJob::dispatch($name);
6263

63-
$this->notification->twoColumn($name, '<fg=blue;options=bold>PENDING</>');
64+
$this->notification->twoColumn($name, StatusEnum::Pending->toColor());
6465

6566
return;
6667
}

0 commit comments

Comments
 (0)