<?php

namespace App\Domain\Questions\Stages;

use App\Services\AiQuestionStructService;

class ClassifyQuestion
{
    public function __construct(private readonly AiQuestionStructService $service)
    {
    }

    public function handle(array $payload, \Closure $next): array
    {
        $payload['question_type'] = $this->service->classifyQuestionType(
            (string) ($payload['stem'] ?? ''),
            $payload['options'] ?? []
        );

        return $next($payload);
    }
}
