<?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\UserCrossAuthenticationValidation;

class CanCrossAuthenticateUser extends AbstractRule
{

    /** @var UserCrossAuthenticationValidation */
    private $userCrossAuthenticationValidation;

    /**
     * CanCrossAuthenticateUser constructor.
     * @param UserCrossAuthenticationValidation $userCrossAuthenticationValidation
     */
    public function __construct(UserCrossAuthenticationValidation $userCrossAuthenticationValidation)
    {
        $this->userCrossAuthenticationValidation = $userCrossAuthenticationValidation;
    }

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

    }


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

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