<?php

namespace App\Domain\Commissions\Enums;

/** How a rule turns an event into an amount (§13A). */
enum CommissionBasis: string
{
    case Fixed = 'fixed';
    case PercentOfCollection = 'percent_of_collection';
    case PercentOfInvoice = 'percent_of_invoice';

    public function label(): string
    {
        return match ($this) {
            self::Fixed => 'Fixed amount',
            self::PercentOfCollection => 'Percentage of the payment collected',
            self::PercentOfInvoice => 'Percentage of the invoice total',
        };
    }

    public function needsRate(): bool
    {
        return $this !== self::Fixed;
    }

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