<?php

declare(strict_types=1);

namespace KupShop\KafkaBundle\DBChanges;

enum DBChangeTypeEnum: string
{
    case INSERT = 'c';
    case UPDATE = 'u';
    case DELETE = 'd';
    case UNKNOWN = 'unknown';

    public static function tryFromLegacy(string $name): static
    {
        return match ($name) {
            'insert' => DBChangeTypeEnum::INSERT,
            'update_after' => DBChangeTypeEnum::UPDATE,
            'delete' => DBChangeTypeEnum::DELETE,
            default => DBChangeTypeEnum::UNKNOWN,
        };
    }
}
