<?php

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


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

class CanUpdateClaudePrompt extends AbstractRule
{

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


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

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

}
