Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum EventState: string
|
|
{
|
|
case Scheduled = 'scheduled';
|
|
case Preparing = 'preparing';
|
|
case Today = 'today';
|
|
case Overdue = 'overdue';
|
|
case Done = 'done';
|
|
case Expired = 'expired';
|
|
case Withdrawn = 'withdrawn';
|
|
|
|
public function isTerminal(): bool
|
|
{
|
|
return in_array($this, [self::Done, self::Expired, self::Withdrawn], true);
|
|
}
|
|
|
|
/** Состояния, в которых ядро напоминает. */
|
|
public function isActive(): bool
|
|
{
|
|
return in_array($this, [self::Preparing, self::Today, self::Overdue], true);
|
|
}
|
|
|
|
public function countsInBadge(): bool
|
|
{
|
|
return in_array($this, [self::Today, self::Overdue], true);
|
|
}
|
|
|
|
/** @return list<string> */
|
|
public static function nonTerminalValues(): array
|
|
{
|
|
return array_values(array_map(
|
|
fn (self $s) => $s->value,
|
|
array_filter(self::cases(), fn (self $s) => ! $s->isTerminal()),
|
|
));
|
|
}
|
|
|
|
/** @return list<string> */
|
|
public static function badgeValues(): array
|
|
{
|
|
return array_values(array_map(
|
|
fn (self $s) => $s->value,
|
|
array_filter(self::cases(), fn (self $s) => $s->countsInBadge()),
|
|
));
|
|
}
|
|
}
|