<?php

namespace CouponsPlus\App\Conditions\BuiltIn\Conditions\Base;

use CouponsPlus\App\Conditions\Condition;
use CouponsPlus\App\Quantities\AmountValidator;
use CouponsPlus\Original\Collections\Collection;
use CouponsPlus\Original\Collections\Mapper\Types;

#[\AllowDynamicProperties]
Abstract 
Class Subtotal extends Condition
{
    abstract protected function getSubtotal() : float;
    abstract protected function getAmountOptions() : array;

    final protected function test() : bool
    {
        return $this->testAmount($this->getSubtotal());
    }

    /**
     * @return bool
     */
    protected function testAmount(float $amount): bool
    {
        (object)$amountValidator = new AmountValidator($this->getAmountOptions());

        $amountValidator->setAmount($amount);

        return $amountValidator->isValid();
    }
}