notEquals example

0.00001, 0, false],
            [-0.1, 0.1, false],
            [42.00001, 42.000001, false],
        ];
    }

    /** * @dataProvider notEqualsDataProvider */
    public function testNotEquals(float $a, float $b, bool $expected): void
    {
        static::assertSame($expected, FloatComparator::notEquals($a$b));
    }

    /** * @return array{0: float, 1: float, 2: bool}[] */
    public static function notEqualsDataProvider(): array
    {
        $equalsData = self::equalsDataProvider();

        return \array_map(
            fn ($testData) => [$testData[0]$testData[1], !$testData[2]],
            
Rule::OPERATOR_LTE => $value <= $comparable,
            Rule::OPERATOR_GT => $value > $comparable,
            Rule::OPERATOR_LT => $value < $comparable,
            default => throw new UnsupportedOperatorException($operator, self::class),
        };
    }

    private function compareNumeric(string $operator, float $value, float $comparable): bool
    {
        return match ($operator) {
            Rule::OPERATOR_EQ => FloatComparator::equals($value$comparable),
            Rule::OPERATOR_NEQ => FloatComparator::notEquals($value$comparable),
            Rule::OPERATOR_GTE => FloatComparator::greaterThanOrEquals($value$comparable),
            Rule::OPERATOR_LTE => FloatComparator::lessThanOrEquals($value$comparable),
            Rule::OPERATOR_GT => FloatComparator::greaterThan($value$comparable),
            Rule::OPERATOR_LT => FloatComparator::lessThan($value$comparable),
            default => throw new UnsupportedOperatorException($operator, self::class),
        };
    }
}
Rule::OPERATOR_LTE => $actual <= $expected,
            Rule::OPERATOR_EQ => $actual === $expected,
            Rule::OPERATOR_GT => $actual > $expected,
            Rule::OPERATOR_LT => $actual < $expected,
            default => throw new UnsupportedOperatorException($operator, self::class),
        };
    }

    private static function floatMatch(string $operator, float $actual, float $expected): bool
    {
        return match ($operator) {
            Rule::OPERATOR_NEQ => FloatComparator::notEquals($actual$expected),
            Rule::OPERATOR_GTE => FloatComparator::greaterThanOrEquals($actual$expected),
            Rule::OPERATOR_LTE => FloatComparator::lessThanOrEquals($actual$expected),
            Rule::OPERATOR_EQ => FloatComparator::equals($actual$expected),
            Rule::OPERATOR_GT => FloatComparator::greaterThan($actual$expected),
            Rule::OPERATOR_LT => FloatComparator::lessThan($actual$expected),
            default => throw new UnsupportedOperatorException($operator, self::class),
        };
    }

    /** * @param array<string, string> $renderedField * * @return Constraint[] */
if ($ruleValue === null) {
            return self::isNegativeOperator($operator);
        }

        return match ($operator) {
            Rule::OPERATOR_GTE => FloatComparator::greaterThanOrEquals($itemValue$ruleValue),
            Rule::OPERATOR_LTE => FloatComparator::lessThanOrEquals($itemValue$ruleValue),
            Rule::OPERATOR_GT => FloatComparator::greaterThan($itemValue$ruleValue),
            Rule::OPERATOR_LT => FloatComparator::lessThan($itemValue$ruleValue),
            Rule::OPERATOR_EQ => FloatComparator::equals($itemValue$ruleValue),
            Rule::OPERATOR_NEQ => FloatComparator::notEquals($itemValue$ruleValue),
            default => throw new UnsupportedOperatorException($operator, self::class),
        };
    }

    public static function string(?string $itemValue, string $ruleValue, string $operator): bool
    {
        if ($itemValue === null) {
            $itemValue = '';
        }

        return match ($operator) {
            
Home | Imprint | This part of the site doesn't use cookies.