<?php

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

use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
use App\Classes\ValueObjects\Constants\RoleTypes;

class CanUpdateCompanyModule extends AbstractRule
{

    /**
     * CanUpdateCompanyModule constructor.
     */
    public function __construct()
    {
    }

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

        return false;
    }

    /**
     * @param $object
     * @return bool
     * @throws \App\Classes\Exceptions\RequestValidationException
     */
    protected function validators($object): bool
    {
        return true;
    }

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