<?php

namespace CouponsPlus\App\Coupon\Tree\ItemSetsToDiscount;

use CouponsPlus\Original\Collections\Collection;
use CouponsPlus\App\Coupon\Tree\Abilities\ItemToDiscount;

/**
 * These represent a set of contexts (groups) that can be applied to products in the cart.
 * Eg: [categories a and b, excluding products c and d] | [brands x and y] | [another group]
 *
 * We'll choose the cheapest from the result of those groups.
 */
class ProductContextsToDiscount implements ItemToDiscount
{

    protected Collection $contextsData;
    protected ProductDiscountOptions $discountOptions;

    public function __construct(Collection $contextsData, ProductDiscountOptions $discountOptions)
    {
        $this->contextsData = $contextsData;
        $this->discountOptions = $discountOptions;
    }

    public function getSubject(): Collection
    {
        return $this->contextsData;
    }

    public function getDiscountOptions(): ProductDiscountOptions
    {
        return $this->discountOptions;
    }

    /**
     * This is always false because we have a pool of non-specific products (categories, tags, brands, etc.)
     */
    public function canBeAutomaticallyAddedToTheCart(): bool
    {
        return false;
    }

    /**
     * Let's just do true for now and them maybe add intelligence later (very complex logic)
     */
    public function canBeManuallyAddedToTheCart(): bool
    {
        return true;
    }
}