<?php

namespace Kylin\LawCase\Enums;

/**
 * 案件状态枚举
 */
enum CaseStatus: string
{
    case CONSULTATION = 'consultation';   // 咨询
    case FILING = 'filing';              // 立案
    case HEARING = 'hearing';            // 审理
    case EXECUTION = 'execution';        // 执行
    case CLOSED = 'closed';              // 结案
    case ARCHIVED = 'archived';          // 归档

    public function label(): string
    {
        return match ($this) {
            self::CONSULTATION => '咨询',
            self::FILING => '立案',
            self::HEARING => '审理',
            self::EXECUTION => '执行',
            self::CLOSED => '结案',
            self::ARCHIVED => '归档',
        };
    }

    public function canTransitionTo(self $status): bool
    {
        return match ($this) {
            self::CONSULTATION => $status === self::FILING,
            self::FILING => $status === self::HEARING,
            self::HEARING => in_array($status, [self::EXECUTION, self::CLOSED]),
            self::EXECUTION => $status === self::CLOSED,
            self::CLOSED => $status === self::ARCHIVED,
            self::ARCHIVED => false,
        };
    }
}
