<?php

namespace CouponsPlus\App\Coupon\Tree;

use CouponsPlus\App\Conditions\ItemsSet;
use CouponsPlus\Original\Collections\Collection;
use CouponsPlus\App\Coupon\Tree\Abilities\FilterableGroup;
use CouponsPlus\App\Conditions\Abilities\TestableComposite;

class SequentialTestableGroup implements FilterableGroup
{
    public function filter(Collection $testables, ItemsSet $passedItems): ItemsSet
    {
        /** @var TestableComposite $testable */
        foreach ($testables->asArray() as $testable) {
            $passedItems = $testable->filterSet($passedItems);
        }

        return $passedItems;
    }
}