<?php

namespace App\Classes\Modules\KeyValuePairs\Standards\Rules;


use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\KeyValuePairs\Standards\Validators\CreateClaudePromptValidation;
use App\Classes\Modules\KeyValuePairs\DataTransferObjects\CreateClaudePromptDTO;
use App\Classes\ValueObjects\Constants\RoleTypes;
use Illuminate\Support\Facades\Auth;

class CanCreateClaudePrompt extends AbstractRule
{

    /** @var CreateClaudePromptValidation */
    private $validation;

    /**
     * CanCreateClaudePrompt constructor.
     * @param CreateClaudePromptValidation $validation
     */
    public function __construct(CreateClaudePromptValidation $validation)
    {
        $this->validation = $validation;
    }

    /**
     * @return bool
     */
    protected function authorized($object): bool
    {
        if (in_array(Auth::user()->type, RoleTypes::ADMIN_ROLES)) {
            return true;
        }
        return false;
    }

    /**
     * @param CreateClaudePromptDTO $object
     * @return bool
     * @throws \App\Classes\Exceptions\RequestValidationException
     */
    protected function validators($object): bool
    {
        return $this->validation->validate($object);
    }

    /**
     * @param CreateChatGPTPromptDTO $object
     * @return bool
     */
    protected function criteria($object): bool
    {
        return true;
    }
}
