<?php

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


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

class CanUpdateChatGPTPrompt extends AbstractRule
{

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


    /**
     * CanUpdateChatGPTPrompt constructor.
     * @param UpdateChatGPTPromptValidation $validation
     */
    public function __construct(UpdateChatGPTPromptValidation $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 UpdateChatGPTPromptDTO $object
     * @return bool
     * @throws \App\Classes\Exceptions\RequestValidationException
     */
    protected function validators($object): bool
    {
        return $this->validation->validate($object);
    }

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

}
