<?php

namespace CouponsPlus\App\Coupon\Tree\Sets;

use CouponsPlus\App\Conditions\ItemsSet;
use CouponsPlus\App\Conditions\Abilities\ItemsSetFilter;

class KeepsSameSorterItemsSetFiltererDecorator extends ItemsSetFilterDecorator implements ItemsSetFilter
{
// this iwll pass the original sorter to the given itemsset reult
// use this, among other places, in the subsetsunm filtere that uses that!
    public function filterSet(ItemsSet $itemsSet): ItemsSet
    {
        $result = $this->itemsSetFilter->filterSet($itemsSet);

        // this is the original sorter
        $result->setItemsSorter($itemsSet->getItemsSorter());

        return $result;
    }
}

/**
 * and maybe a itemssetfilter composite to replace the composite filter
 * so, like, instead of manually instantiaing the new IntersectionFilter and new SubsetFilter, just do one per class,
 * add them to a itemssetfilter composite like so:
 * new ItemsSetFilterComposite([
 *      new IntersectionFilter,
 *      new SubsetFilter,
 * ])
 *
 * then maybe eve create a SorterPreserverItemsSetFilterComposite:
 *
 * new SorterPreserverItemsSetFilterComposite([
 *      new IntersectionFilter,
 *      new SubsetFilter,
 * ])
 *
 * and the for each call, we pass the original sorter to the itemsset result to the next filter
 */