<?php

namespace CouponsPlus\App\Coupon\Tree\ItemSetsToDiscount;

use CouponsPlus\Original\Characters\StringManager;
use CouponsPlus\Original\Collections\MappedObject;

/**
 * A simple Data Transfer Object, idc if mutable. I don't want to create getters and setters.
 */
class ProductDiscountOptions
{
    public StringManager $discountType;
    public float $discountAmount;
    /**
     * @var int|MappedObject
     */
    public $quantity;

    /**
     * @param int|MappedObject $quantity
     */
    public function __construct(
        StringManager $discountType,
        float $discountAmount,
        $quantity
    )
    {
        $this->quantity = $quantity;
        $this->discountAmount = $discountAmount;
        $this->discountType = $discountType;
    }

    public function canFillQuantity(int $getTotalQuantity): bool
    {
        if ($this->quantity instanceof MappedObject) {
            switch ($this->quantity->type) {
                case 'any':
                    return $getTotalQuantity >= 1;
                default:
                    // here well dispatch to amount validator when it's due time
                    return false;
            }
        }

        return $this->quantity <= $getTotalQuantity;
    }
}