<?php

namespace App\Domain\Participant\Enums;

/**
 * Whether a participant belongs to the organisation or is a guest of it.
 *
 * The two stored values never change. What a human is shown for them is a
 * per-branch setting — عضو in a club, مقيم in a compound, مشترك on a beach —
 * so label() asks the branch instead of answering itself. Pass a branch id
 * when labelling a record from a branch other than the one on screen.
 */
enum MembershipType: string
{
    case Member = 'member';
    case NonMember = 'non_member';

    public function label(?int $branchId = null): string
    {
        return match ($this) {
            self::Member => term('member', $branchId),
            self::NonMember => term('non_member', $branchId),
        };
    }

    /**
     * @return array<string, string>  stored value => branch label
     */
    public static function options(?int $branchId = null): array
    {
        return [
            self::Member->value => self::Member->label($branchId),
            self::NonMember->value => self::NonMember->label($branchId),
        ];
    }
}
