getExpectedValue example

/** * @throws UnsupportedOperatorException */
    private function isCustomFieldValid(LineItem $lineItem): bool
    {
        $customFields = $lineItem->getPayloadValue('customFields');
        if ($customFields === null) {
            return RuleComparison::isNegativeOperator($this->operator);
        }

        $actual = $this->getValue($customFields$this->renderedField);
        $expected = $this->getExpectedValue($this->renderedFieldValue, $this->renderedField);

        if ($actual === null) {
            if ($this->operator === self::OPERATOR_NEQ) {
                return $actual !== $expected;
            }

            return false;
        }

        return match ($this->operator) {
            self::OPERATOR_NEQ => $actual !== $expected,
            

        ];
    }

    /** * @param array<string, string> $renderedField * @param array<string, mixed> $customFields */
    public static function match(array $renderedField, string|int|bool|null|float $renderedFieldValue, string $operator, array $customFields): bool
    {
        $actual = self::getValue($customFields$renderedField);
        $expected = self::getExpectedValue($renderedFieldValue$renderedField);

        if ($actual === null) {
            if ($operator === Rule::OPERATOR_NEQ) {
                return $actual !== $expected;
            }

            return false;
        }

        if (self::isFloat($renderedField)) {
            return self::floatMatch($operator(float) $actual(float) $expected);
        }
Home | Imprint | This part of the site doesn't use cookies.