52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App;
|
||
|
|
|
||
|
|
enum TodoStatus: string
|
||
|
|
{
|
||
|
|
case Open = 'open';
|
||
|
|
case InProgress = 'in-progress';
|
||
|
|
case OnHold = 'on-hold';
|
||
|
|
case Blocked = 'blocked';
|
||
|
|
case Cancelled = 'cancelled';
|
||
|
|
case Deferred = 'deferred';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the human-friendly label for the status.
|
||
|
|
*/
|
||
|
|
public function label(): string
|
||
|
|
{
|
||
|
|
return match ($this) {
|
||
|
|
self::Open => 'Open',
|
||
|
|
self::InProgress => 'In Progress',
|
||
|
|
self::OnHold => 'On Hold',
|
||
|
|
self::Blocked => 'Blocked',
|
||
|
|
self::Cancelled => 'Cancelled',
|
||
|
|
self::Deferred => 'Deferred',
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the Flux badge color used to render the status.
|
||
|
|
*/
|
||
|
|
public function badgeColor(): string
|
||
|
|
{
|
||
|
|
return match ($this) {
|
||
|
|
self::Open => 'blue',
|
||
|
|
self::InProgress => 'green',
|
||
|
|
self::OnHold => 'amber',
|
||
|
|
self::Blocked => 'red',
|
||
|
|
self::Cancelled => 'zinc',
|
||
|
|
self::Deferred => 'purple',
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Determine whether the status means the todo is no longer actionable.
|
||
|
|
*/
|
||
|
|
public function isTerminal(): bool
|
||
|
|
{
|
||
|
|
return in_array($this, [self::Cancelled, self::Deferred], true);
|
||
|
|
}
|
||
|
|
}
|