<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Modificator;

use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Modificator\SingleModificator;
use ArrayObject;
use WC_Product;
class SingleModificatorCollection extends ArrayObject
{
    public function add_condition(SingleModificator $condition): void
    {
        $this->append($condition);
    }
    /**
     *
     * @param WC_Product $product
     * @param mixed $value
     * @return mixed
     */
    public function get_value(WC_Product $product, $value)
    {
        /**
         * @var SingleModificator $value
         */
        foreach ($this as $single_modificator) {
            if ($single_modificator->is_valid($product)) {
                return $single_modificator->get_modified_value($value);
            }
        }
        return $value;
    }
}
