<?php

namespace App\Domain\Payroll\Enums;

/** Employee loan lifecycle (§55). */
enum LoanStatus: string
{
    case Requested = 'requested';
    case Approved = 'approved';
    case Disbursed = 'disbursed';
    case Settled = 'settled';
    case Rejected = 'rejected';
    case Cancelled = 'cancelled';

    public function label(): string
    {
        return match ($this) {
            self::Requested => 'Requested',
            self::Approved => 'Approved',
            self::Disbursed => 'Being Recovered',
            self::Settled => 'Settled',
            self::Rejected => 'Rejected',
            self::Cancelled => 'Cancelled',
        };
    }

    /** Only a disbursed loan is deducted from a pay packet. */
    public function isRecovering(): bool
    {
        return $this === self::Disbursed;
    }

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