<?php

namespace CouponsPlus\App\Coupon\Attributes\Factories;

use WP_Term;
use WC_Product_Attribute;
use CouponsPlus\Original\Collections\Collection;
use CouponsPlus\App\Coupon\Attributes\AttributeMatcher;
use CouponsPlus\App\Coupon\Attributes\AttributeToMatch;
use CouponsPlus\App\Coupon\Attributes\Data\GlobalAttributeData;

class AttributeMatcherFactory
{

    /**
     * @var GlobalAttributeDataFactory
     */
    protected $globalAttributeDataFactory;

    public function __construct(GlobalAttributeDataFactory $globalAttributeDataFactory)
    {
        $this->globalAttributeDataFactory = $globalAttributeDataFactory;
    }

    public function create(string $type,  int $attributeId, array $valuesToUse) : AttributeMatcher
    {
        return new AttributeMatcher(
            new AttributeToMatch(
                $type,
                $this->globalAttributeDataFactory->create($attributeId, $valuesToUse ?: null)
            )
        );
    }
}