<?php

namespace App\Classes\Modules\HelpMenu\Processors;

use App\Classes\Modules\HelpMenu\Services\FetchesHelpMenuQuestion;
use ErrorException;
use Illuminate\Http\Request;


class FetchFirstQuestionQAProcessor
{
    /** @var FetchesHelpMenuQuestion */
    private $fetchesHelpMenuQuestion;

    /**
     * FetchFirstQuestionQAProcessor constructor.
     * @param FetchesHelpMenuQuestion $fetchesHelpMenuQuestion
     */
    public function __construct(FetchesHelpMenuQuestion $fetchesHelpMenuQuestion)
    {
        $this->fetchesHelpMenuQuestion = $fetchesHelpMenuQuestion;
    }

    public function execute(Request $request){
        try {
            $query = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => $request->route('set_id')]);
            return $query;
        } catch (\Exception $exception){
            throw new ErrorException($exception->getMessage(), $exception->getCode());
        }
    }
}
