<?php

namespace Modules\SpecialAttendance\Http\Enums;

enum DeductionTypeEnum: string
{
    case FullDay = '1';
    case HalfDay = '0.5';

    public static function toArray(): array
    {
        return array_column(self::cases(), 'value', 'value');
    }

    public static function keys(): array
    {
        return array_column(self::cases(), 'name');
    }

    public static function getKey(string $value): ?string
    {
        foreach (self::cases() as $case) {
            if ($case->value === $value) {
                return $case->name;
            }
        }

        return null; // Return null if no matching value is found
    }

    public static function getValue(string $key): ?string
    {
        foreach (self::cases() as $case) {
            if ($case->name === $key) {
                return $case->value;
            }
        }

        return null; // Return null if no matching key is found
    }
}
