<?php

namespace CouponsPlus\App\Coupon\Tree\Sets;

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

class ItemsSetFilterComposite implements ItemsSetFilter
{
    // create a constrcutor tat accepts an array of ItemsSetFilter
    protected array $itemsSetFilters;

    public function __construct(
        array $itemsSetFilters
    ) {
        $this->itemsSetFilters = $itemsSetFilters;
    }

    public function filterSet(ItemsSet $itemsSet): ItemsSet
    {
        foreach ($this->itemsSetFilters as $itemsSetFilter) {
            $itemsSet = $itemsSetFilter->filterSet($itemsSet);
        }

        return $itemsSet;
    }
}