<?php

declare(strict_types=1);

namespace App\Services\Enhance;

use App\Models\EnhanceJob;
use App\Services\Enhance\Processors\ExternalWorkerEnhanceProcessor;
use App\Services\Enhance\Processors\StubEnhanceProcessor;
use RuntimeException;

final class EnhanceProcessorFactory
{
    public function __construct(
        private readonly StubEnhanceProcessor $stubProcessor,
        private readonly ExternalWorkerEnhanceProcessor $externalWorkerProcessor,
    ) {
    }

    public function make(string $engine): EnhanceProcessor
    {
        return match ($engine) {
            EnhanceJob::ENGINE_STUB => $this->stubProcessor,
            EnhanceJob::ENGINE_EXTERNAL_WORKER => $this->externalWorkerProcessor,
            default => throw new RuntimeException('Unknown enhance processor engine.'),
        };
    }
}