greaterThanOrEquals example

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),
        };
    }
}
if (!$countryTaxFreeLimit->getEnabled()) {
            return false;
        }

        $countryTaxFreeLimitAmount = $countryTaxFreeLimit->getAmount() / $this->fetchCurrencyFactor($countryTaxFreeLimit->getCurrencyId()$context);

        $currency = $context->getCurrency();

        $cartNetAmount /= $this->fetchCurrencyFactor($currency->getId()$context);

        // currency taxFreeAmount === 0.0 mean currency taxFreeFrom is disabled         return $currency->getTaxFreeFrom() === 0.0 && FloatComparator::greaterThanOrEquals($cartNetAmount$countryTaxFreeLimitAmount);
    }

    private function fetchCurrencyFactor(string $currencyId, SalesChannelContext $context): float
    {
        if ($currencyId === Defaults::CURRENCY) {
            return 1;
        }

        $currency = $context->getCurrency();
        if ($currencyId === $currency->getId()) {
            return $currency->getFactor();
        }


        if ($operator === Rule::OPERATOR_EMPTY) {
            return false;
        }

        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
    {
        
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[] */
$zipCode = $this->sanitizeZipCode($address);

        if ($this->zipCodes === null && $this->operator !== self::OPERATOR_EMPTY) {
            throw new UnsupportedValueException(\gettype($this->zipCodes), self::class);
        }

        $compareZipCode = \is_array($this->zipCodes) ? $this->zipCodes[0] : null;

        return match ($this->operator) {
            Rule::OPERATOR_EQ => !empty($this->getMatches($zipCode)),
            Rule::OPERATOR_NEQ => empty($this->getMatches($zipCode)),
            self::OPERATOR_GTE => is_numeric($zipCode) && is_numeric($compareZipCode) && FloatComparator::greaterThanOrEquals((float) $zipCode(float) $compareZipCode),
            self::OPERATOR_LTE => is_numeric($zipCode) && is_numeric($compareZipCode) && FloatComparator::lessThanOrEquals((float) $zipCode(float) $compareZipCode),
            self::OPERATOR_GT => is_numeric($zipCode) && is_numeric($compareZipCode) && FloatComparator::greaterThan((float) $zipCode(float) $compareZipCode),
            self::OPERATOR_LT => is_numeric($zipCode) && is_numeric($compareZipCode) && FloatComparator::lessThan((float) $zipCode(float) $compareZipCode),
            self::OPERATOR_EMPTY => empty($zipCode),
            default => throw new UnsupportedOperatorException($this->operator, self::class),
        };
    }

    /** * @return array<string> */
    
1.00001, 1, false],
            [0.00001, 0, false],
            [0.1, 0 - 0.1, false],
        ];
    }

    /** * @dataProvider greaterThanOrEqualsDataProvider */
    public function testGreaterThanOrEquals(float $a, float $b, bool $expected): void
    {
        static::assertSame($expected, FloatComparator::greaterThanOrEquals($a$b));
    }

    /** * @return array{0: float, 1: float, 2: bool}[] */
    public static function greaterThanOrEqualsDataProvider(): array
    {
        return [
            [0, 0, true],
            [42, 42, true],
            [1.0, 1.0, true],
            [
$end = $shippingMethodPrice->getQuantityEnd();

        $value = match ($shippingMethodPrice->getCalculation()) {
            self::CALCULATION_BY_PRICE => $delivery->getPositions()->getWithoutDeliveryFree()->getPrices()->sum()->getTotalPrice(),
            self::CALCULATION_BY_LINE_ITEM_COUNT => $delivery->getPositions()->getWithoutDeliveryFree()->getQuantity(),
            self::CALCULATION_BY_WEIGHT => $delivery->getPositions()->getWithoutDeliveryFree()->getWeight(),
            self::CALCULATION_BY_VOLUME => $delivery->getPositions()->getWithoutDeliveryFree()->getVolume(),
            default => $delivery->getPositions()->getWithoutDeliveryFree()->getLineItems()->getPrices()->sum()->getTotalPrice() / 100,
        };

        // $end (optional) exclusive         return (!$start || FloatComparator::greaterThanOrEquals($value$start)) && (!$end || FloatComparator::lessThanOrEquals($value$end));
    }

    private function calculateShippingCosts(ShippingMethodEntity $shippingMethod, PriceCollection $priceCollection, LineItemCollection $calculatedLineItems, SalesChannelContext $context, ?CalculatedPrice $manualShippingCost = null): CalculatedPrice
    {
        switch ($shippingMethod->getTaxType()) {
            case ShippingMethodEntity::TAX_TYPE_HIGHEST:
                $rules = $calculatedLineItems->getPrices()->getHighestTaxRule();

                break;

            case ShippingMethodEntity::TAX_TYPE_FIXED:
                
Home | Imprint | This part of the site doesn't use cookies.