<?php

namespace Modules\Stock\Enum;

use Exception;

enum ImputationEnum
{
    case SI;
    case SCA;
    case CDC;

    /**
     * @throws Exception
     */
    public static function tryFrom(string $name): ImputationEnum
    {
        return match ($name) {
            self::SI->name => self::SI,
            self::SCA->name => self::SCA,
            self::CDC->name => self::CDC,
            default => throw new Exception('Aucun cas n\'existe pour le nom ' . $name)
        };
    }
}
