<?php

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

use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\Accounts\DataTransferObjects\RegistrationObject;
use App\Classes\Modules\Accounts\Standards\Validators\UserRegistrationValidation;

class CanRegisterUser extends AbstractRule
{

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

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

    /**
     * @return bool
     */
    protected function authorized(): bool
    {
        // TODO  Set Authorization rules
        return true;
    }

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

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