<?php

namespace CouponsPlus\App\Coupon\Tree\Testable;

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

/**
 * This class is basically because we ain't got no union types in php 7.4
 */
class TestableCompositeWithCollection implements TestableComposite, TestableCompositeCollection
{
    /**
     * @var TestableCompositeCollection&TestableComposite
     */
    protected $testableCompositeWithCollection;

    /**
     * @param TestableCompositeCollection&TestableComposite $testableComposite
     */
    public function __construct($testableComposite)
    {
        $this->testableCompositeWithCollection = $testableComposite;
    }

    public function filterSet(ItemsSet $itemsSet): ItemsSet
    {
        return $this->testableCompositeWithCollection->filterSet($itemsSet);
    }

    public function get(): Collection
    {
        return $this->testableCompositeWithCollection->get();
    }

    public function add(TestableComposite $testableComposite)
    {
        $this->testableCompositeWithCollection->add($testableComposite);
    }
}