<?php

namespace CouponsPlus\App\Coupon\Attributes\Data;

use WP_Term;
use CouponsPlus\Original\Characters\StringManager;
use CouponsPlus\app\coupon\attributes\abilities\AttributeData;
use CouponsPlus\app\coupon\attributes\abilities\AttributeValueData;

class GlobalAttributeValueData implements AttributeValueData
{
    /**
     * @var WP_Term
     */
    protected $data;
    /**
     * @var AttributeValueData
     */
    protected $attributeData;

    public function __construct(WP_Term $data, AttributeData $attributeData)
    {
        $this->data = $data;
        $this->attributeData = $attributeData;
    }

    public function getId()
    {
        return $this->data->term_id;
    }

    public function getKey(): StringManager
    {
        return new StringManager($this->data->slug);
    }

    public function getValue(): StringManager
    {
        return new StringManager($this->data->name);
    }

    public function getAttribute(): AttributeData
    {
        return $this->attributeData;
    }
}

/**
 * $localAttributeValueData = new LocalAttributeValueData('Blue');
 *
 * $this->assertEquals('Blue', $localAttributeValueData->getId());
 * $this->assertEquals('Blue', $localAttributeValueData->getKey());
 * $this->assertEquals('Blue', $localAttributeValueData->getValue());
 */