Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
18 / 18 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| CronJobStatusData | |
100.00% |
18 / 18 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| jsonSerialize | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Domain\SuperAdmin\Data; |
| 6 | |
| 7 | use App\Support\Row; |
| 8 | use JsonSerializable; |
| 9 | |
| 10 | /** |
| 11 | * Last-run status snapshot for one scheduled console command — used by |
| 12 | * the super-admin dashboard tile (FSC-114). Source data is queried from |
| 13 | * the existing accrual / snapshot / transactions tables; no dedicated |
| 14 | * cron_run table needed. |
| 15 | */ |
| 16 | final class CronJobStatusData implements JsonSerializable |
| 17 | { |
| 18 | /** |
| 19 | * Job status taxonomy: |
| 20 | * - "healthy" — last run within the expected window |
| 21 | * - "warning" — last run is approaching the staleness threshold |
| 22 | * - "stale" — last run is past the staleness threshold |
| 23 | * - "never_run" — no run has been recorded |
| 24 | */ |
| 25 | public string $jobName; |
| 26 | |
| 27 | public string $displayName; |
| 28 | |
| 29 | public string $expectedFrequency; |
| 30 | |
| 31 | public ?string $lastRunAt; |
| 32 | |
| 33 | public ?string $lastRunFor; |
| 34 | |
| 35 | public int $accountsAffected; |
| 36 | |
| 37 | public ?string $totalAmount; |
| 38 | |
| 39 | public string $status; |
| 40 | |
| 41 | /** |
| 42 | * @param array<string, mixed> $data |
| 43 | */ |
| 44 | public function __construct(array $data) |
| 45 | { |
| 46 | $this->jobName = Row::string($data, 'jobName'); |
| 47 | $this->displayName = Row::string($data, 'displayName'); |
| 48 | $this->expectedFrequency = Row::string($data, 'expectedFrequency'); |
| 49 | $this->lastRunAt = Row::nullableString($data, 'lastRunAt'); |
| 50 | $this->lastRunFor = Row::nullableString($data, 'lastRunFor'); |
| 51 | $this->accountsAffected = Row::int($data, 'accountsAffected'); |
| 52 | $this->totalAmount = Row::nullableString($data, 'totalAmount'); |
| 53 | $this->status = Row::string($data, 'status'); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @return array<string, mixed> |
| 58 | */ |
| 59 | public function jsonSerialize(): array |
| 60 | { |
| 61 | return [ |
| 62 | 'jobName' => $this->jobName, |
| 63 | 'displayName' => $this->displayName, |
| 64 | 'expectedFrequency' => $this->expectedFrequency, |
| 65 | 'lastRunAt' => $this->lastRunAt, |
| 66 | 'lastRunFor' => $this->lastRunFor, |
| 67 | 'accountsAffected' => $this->accountsAffected, |
| 68 | 'totalAmount' => $this->totalAmount, |
| 69 | 'status' => $this->status, |
| 70 | ]; |
| 71 | } |
| 72 | } |