<?php

namespace App\Domain\Shared\Enums;

/**
 * What a participant joining part-way through a month pays for.
 *
 * RemainingSessions replaced an older "remaining days" rule. Days were the
 * wrong unit: a programme training Sunday and Tuesday holds no sessions at all
 * over a long weekend, so someone joining on the 22nd was charged for a third
 * of a month in which they might train twice. Sessions are what is sold, so
 * sessions are what is counted.
 */
enum ProrationMode: string
{
    case FullMonth = 'full_month';
    case HalfMonth = 'half_month';
    case RemainingSessions = 'remaining_sessions';

    public function label(): string
    {
        return match ($this) {
            self::FullMonth => 'شهر كامل',
            self::HalfMonth => 'نصف شهر',
            self::RemainingSessions => 'باقي تمرينات الشهر',
        };
    }

    public function hint(): string
    {
        return match ($this) {
            self::FullMonth => 'الاشتراك كامل زي أي حد بدأ من أول الشهر',
            self::HalfMonth => 'نصف قيمة الاشتراك',
            self::RemainingSessions => 'بيدفع على عدد التمرينات الباقية في الشهر بس',
        };
    }

    /** @return array<string, string> value => label, for a picker. */
    public static function options(): array
    {
        $out = [];

        foreach (self::cases() as $case) {
            $out[$case->value] = $case->label();
        }

        return $out;
    }
}
