<?php

namespace Helpers\Outil;

use Entity\Model\Enum\ILabelized;
use Helpers\Trad\ITrad;

class EnumHelper
{
    /**
     * @param class-string<ILabelized&\BackedEnum> $enumClass
     * @return array<string|int,string>
     */
    public static function enumToChoice(string $enumClass, ?ITrad $trad): array
    {
        return array_reduce(
            $enumClass::cases(),
            function ($carry, ILabelized $case) use ($trad) {
                $carry[ $case->value ] = $case->getLabel($trad);
                return $carry;
            },
            []
        );
    }
}
