<?php

namespace App\Domain\Expenses\Enums;

/** Expense flow (§39): Request → Approval → Payment → Accounting → Closed. */
enum ExpenseStatus: string
{
    case Requested = 'requested';
    case Approved = 'approved';
    case Rejected = 'rejected';
    case Paid = 'paid';
    case Cancelled = 'cancelled';

    public function label(): string
    {
        return match ($this) {
            self::Requested => 'Awaiting Approval',
            self::Approved => 'Approved',
            self::Rejected => 'Rejected',
            self::Paid => 'Paid',
            self::Cancelled => 'Cancelled',
        };
    }

    public function isClosed(): bool
    {
        return in_array($this, [self::Paid, self::Rejected, self::Cancelled], true);
    }

    public function isEditable(): bool
    {
        return $this === self::Requested;
    }

    /** @return array<int, string> */
    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }
}
