<?php

namespace App\Domain\Commissions\Enums;

/**
 * The verified system events commission can hang off (§13A).
 *
 * Nothing here is ever asserted by the frontend: each case corresponds to
 * something the backend itself observed happening.
 */
enum CommissionTrigger: string
{
    case ApplicantVerified = 'applicant_verified';
    case ApplicantSelected = 'applicant_selected';
    case MedicalPassed = 'medical_passed';
    case VisaApproved = 'visa_approved';
    case TicketConfirmed = 'ticket_confirmed';
    case DeploymentCompleted = 'deployment_completed';
    case PaymentConfirmed = 'payment_confirmed';
    case InvoicePaid = 'invoice_paid';

    public function label(): string
    {
        return match ($this) {
            self::ApplicantVerified => 'Applicant profile verified',
            self::ApplicantSelected => 'Applicant selected by employer',
            self::MedicalPassed => 'Medical passed',
            self::VisaApproved => 'Visa approved',
            self::TicketConfirmed => 'Ticket confirmed',
            self::DeploymentCompleted => 'Deployment completed',
            self::PaymentConfirmed => 'Payment confirmed',
            self::InvoicePaid => 'Invoice fully paid',
        };
    }

    /** Whether an amount comes with this event for a percentage rule. */
    public function carriesAmount(): bool
    {
        return in_array($this, [self::PaymentConfirmed, self::InvoicePaid], true);
    }

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