<?php

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


use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Exceptions\RequestValidationException;
use App\Classes\Modules\Accounts\DataTransferObjects\AuthenticationCredentialsObject;
use App\Classes\Modules\Accounts\Standards\Validators\UserAuthenticationValidation;
use App\Classes\Modules\Accounts\Standards\Validators\UserRegistrationValidation;

class CanCreateUser extends AbstractRule
{

    /** @var UserRegistrationValidation */
    private $userRegistrationValidation;

    /**
     * CanRegisterUser constructor.
     * @param UserRegistrationValidation $userRegistrationValidation
     */
    public function __construct(UserRegistrationValidation $userRegistrationValidation)
    {
        $this->userRegistrationValidation = $userRegistrationValidation;
    }


    /**
     * @return bool
     */
    protected function authorized(): bool
    {
        return true;

    }

    /**
     * @param AuthenticationCredentialsObject $object
     * @return bool
     * @throws RequestValidationException
     */
    protected function validators($object): bool
    {
        return $this->userRegistrationValidation->validate($object);

    }


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

}