<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Modificator\Value;

use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Modificator\ValueModificator;
/**
 *
 * @package WPDesk\Library\DropshippingExport\Modificator\Value
 */
class FixedValueModificator implements ValueModificator
{
    private $parameter = 0;
    public static function get_name(): string
    {
        return 'fixed';
    }
    public static function get_nice_name(): string
    {
        return __('Fixed', 'dropshipping-export-free');
    }
    public function set_parameter($value)
    {
        $value = str_replace(',', '.', trim($value));
        if (is_numeric($value)) {
            $this->parameter = floatval($value);
        }
    }
    public function get_modified_value($value)
    {
        if (empty($this->parameter)) {
            return $value;
        }
        $value = str_replace(',', '.', trim($value));
        if (is_numeric($value)) {
            $value = floatval($value) + $this->parameter;
        }
        return floatval($value);
    }
}
