<?php

namespace App\Domain\Communication\Enums;

/** Support ticket flow (§59). */
enum TicketStatus: string
{
    case Open = 'open';
    case InProgress = 'in_progress';
    case WaitingApplicant = 'waiting_applicant';
    case Escalated = 'escalated';
    case Resolved = 'resolved';
    case Closed = 'closed';

    public function label(): string
    {
        return match ($this) {
            self::Open => 'Open',
            self::InProgress => 'In Progress',
            self::WaitingApplicant => 'Waiting on Applicant',
            self::Escalated => 'Escalated',
            self::Resolved => 'Resolved',
            self::Closed => 'Closed',
        };
    }

    public function isClosed(): bool
    {
        return in_array($this, [self::Resolved, self::Closed], true);
    }

    /**
     * The SLA clock stops while the agency is waiting on the applicant — it is
     * not the agency's delay.
     */
    public function countsTowardsSla(): bool
    {
        return in_array($this, [self::Open, self::InProgress, self::Escalated], true);
    }

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