<?php

namespace CouponsPlus\App\Coupon\Tree\Finders;

use WC_Coupon;
use CouponsPlus\App\Coupon\Tree\Abilities\NodeDataFilterableSet;
use CouponsPlus\App\Coupon\Tree\Testable\SetFiltererFromNodeData;
use CouponsPlus\App\Coupon\Tree\Factories\FilterableGroupFactory;
use CouponsPlus\App\Coupon\Tree\Factories\TestableGroupFactoryFromData;
use CouponsPlus\App\Coupon\Tree\Factories\CachedFilterableGroupFactory;
use CouponsPlus\App\Coupon\Tree\Factories\CachedTestableGroupFactoryFromData;
use CouponsPlus\App\Coupon\Tree\Factories\ContextFromTestableGroupDataFactory;
use CouponsPlus\App\Coupon\Tree\Factories\ConditionFilterOrOfferFromDataFactory;
use CouponsPlus\App\Coupon\Tree\Testable\IgnoreListAdderOnEmptySetFiltererFromNodeData;
use CouponsPlus\App\Coupon\Tree\Testable\EmptySetOnExceptionInProductionSetFiltererFromNodeData;

class ItemsSetFiltererFromDataFactory
{
    public function create(WC_Coupon $coupon) : NodeDataFilterableSet
    {
        return new IgnoreListAdderOnEmptySetFiltererFromNodeData(
        new EmptySetOnExceptionInProductionSetFiltererFromNodeData(
            new SetFiltererFromNodeData(
                new CachedTestableGroupFactoryFromData(
                    new TestableGroupFactoryFromData(
                        new FilterableGroupFactory,
                        new ContextFromTestableGroupDataFactory(
                            new ConditionFilterOrOfferFromDataFactory($coupon)
                            )
                        )
                    )
                )
            )
        );
    }
}