<?php

namespace App\Enums;

enum PaymentMethod: string
{
    case Cash = 'CASH';
    case Cheque = 'CHEQUE';
    case PayOrder = 'PAY_ORDER';
    case BankTransfer = 'BANK_TRANSFER';
    case Other = 'OTHER';

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

    public function label(): string
    {
        return match ($this) {
            self::Cash => 'Cash',
            self::Cheque => 'Cheque',
            self::PayOrder => 'Pay order',
            self::BankTransfer => 'Bank transfer',
            self::Other => 'Other',
        };
    }

    public function requiresReference(): bool
    {
        return $this !== self::Cash;
    }

    public function requiresAccountName(): bool
    {
        return match ($this) {
            self::Cheque, self::PayOrder, self::BankTransfer => true,
            default => false,
        };
    }
}
