Files
cpo_test/laravel/app/Enums/TaskStatus.php
2026-02-06 23:26:56 +07:00

39 lines
897 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Enums;
enum TaskStatus: string
{
case PENDING = 'pending';
case IN_PROGRESS = 'in_progress';
case COMPLETED = 'completed';
public static function values(): array
{
return array_map(fn($case) => $case->value, self::cases());
}
public static function options(): array
{
return [
self::PENDING->value => 'В ожидании',
self::IN_PROGRESS->value => 'В процессе',
self::COMPLETED->value => 'Завершена',
];
}
public function label(): string
{
return match ($this) {
self::PENDING => 'В ожидании',
self::IN_PROGRESS => 'В процессе',
self::COMPLETED => 'Завершена',
};
}
public function isCompleted(): bool
{
return $this === self::COMPLETED;
}
}