<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Conditions;

use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Conditions\Abstraction\Condition;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Conditions\Abstraction\ConditionOperator;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ConditionalLogic\Conditions\Abstraction\ConditionWithValue;
class HigherCondition implements Condition, ConditionWithValue, ConditionOperator
{
    public const SEPARATOR = '|';
    private string $value = '';
    public function is_valid($field_value): bool
    {
        $field_value = is_string($field_value) || is_numeric($field_value) ? strval($field_value) : null;
        foreach ($this->get_values() as $value) {
            if (is_string($field_value) && is_string($value)) {
                $field_value = str_replace(',', '.', $field_value);
                $value = str_replace(',', '.', $value);
                if (\is_numeric($field_value) && \is_numeric($value)) {
                    if (floatval($field_value) > floatval($value)) {
                        return \true;
                    }
                }
            }
        }
        return \false;
    }
    public static function get_operator(): string
    {
        return '>';
    }
    public static function get_operator_value($value): string
    {
        return $value;
    }
    public static function get_name(): string
    {
        return 'higher';
    }
    public static function get_nice_name(): string
    {
        return __('is higher than', 'dropshipping-export-free');
    }
    public function set_value(string $value)
    {
        $this->value = $value;
    }
    public function get_values(): array
    {
        return \explode(self::SEPARATOR, $this->value);
    }
    public function has_multiple_values(): bool
    {
        return count($this->get_values()) > 1;
    }
}
