<?php

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

use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\Affiliate\DataTransferObjects\AffiliateObject;
use App\Classes\Modules\Affiliate\Standards\Validators\AffiliateCreateValidation;

class CanCreateAffiliate extends AbstractRule
{
    /** @var AffiliateCreateValidation */
    private $affiliateCreateValidation;

    /**
     * CanCreateAffiliate constructor.
     * @param AffiliateCreateValidation $affiliateCreateValidation
     */
    public function __construct(AffiliateCreateValidation $affiliateCreateValidation)
    {
        $this->affiliateCreateValidation = $affiliateCreateValidation;
    }

    /**
     * @param AffiliateObject $object
     * @return bool
     */
    protected function authorized($object): bool
    {
        // Authorization is handled by policy in controller
        return true;
    }

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

    /**
     * @param AffiliateObject $object
     * @return bool
     */
    protected function criteria($object): bool
    {
        // No additional criteria needed for affiliate creation
        return true;
    }
}
