<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Modificator;

use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Conditions\Abstraction\Condition;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Fields\Abstraction\Field;
use WC_Product;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Modificator\ValueModificator;
/**
 *
 * @package WPDesk\Library\DropshippingExport\Modificator
 */
class SingleModificator
{
    /**
     *
     * @var Field
     */
    private $field;
    /**
     *
     * @var Condition
     */
    private $condition;
    /**
     *
     * @var ValueModificator
     */
    private $value_modificator;
    public function __construct(Field $field, Condition $condition, ValueModificator $value_modificator)
    {
        $this->field = $field;
        $this->condition = $condition;
        $this->value_modificator = $value_modificator;
    }
    public function is_valid(WC_Product $product): bool
    {
        $field_value = $this->field->get_product_value($product);
        return $this->condition->is_valid($field_value);
    }
    public function get_modified_value($value)
    {
        return $this->value_modificator->get_modified_value($value);
    }
}
