<?php

namespace App\Domain\Payments\Enums;

/** §29 payment methods; cash and bank deposit are the two that matter (§29A). */
enum PaymentMethod: string
{
    case Cash = 'cash';
    case BankDeposit = 'bank_deposit';
    case BankTransfer = 'bank_transfer';
    case Cheque = 'cheque';
    case Bkash = 'bkash';
    case Nagad = 'nagad';
    case Rocket = 'rocket';
    case Card = 'card';
    case Other = 'other';

    public function label(): string
    {
        return match ($this) {
            self::Cash => 'Cash',
            self::BankDeposit => 'Bank Deposit',
            self::BankTransfer => 'Bank Transfer',
            self::Cheque => 'Cheque',
            self::Bkash => 'bKash',
            self::Nagad => 'Nagad',
            self::Rocket => 'Rocket',
            self::Card => 'Card',
            self::Other => 'Other',
        };
    }

    /**
     * Cash is counted the moment the cashier has it. Everything else is a claim
     * about money elsewhere, and is verified before it counts (§29A).
     */
    public function isConfirmedOnReceipt(): bool
    {
        return $this === self::Cash;
    }

    /** Methods that cannot be traced without a reference of some kind. */
    public function requiresReference(): bool
    {
        return ! in_array($this, [self::Cash, self::Other], true);
    }

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