public function calculate(array $variation)
    {
        if (empty(self::$units)) {
            self::$units = array_filter($this->itemUnitApi->findAll(), function (array $unit) {
                return array_key_exists($unit['unitOfMeasurement'], self::$convertionMatrix);
            });
        }

        $variationUnit = $this->getUnitOfVariation($variation);

        if (null === $variationUnit) {
            return 1.0;
        }

        $modifier = self::$convertionMatrix[$variationUnit]['conversion'];

        $content = $variation['unit']['content'] * $modifier;

        if ($content <= 0.25 && 5 !== $variation['unit']['unitId'] && 2 !== $variation['unit']['unitId']) {
            return 0.1 / $modifier;
        }

        return 1.0 / $modifier;
    }
public function calculate(array $variation)
    {
        if (empty(self::$units)) {
            self::$units = array_filter($this->itemUnitApi->findAll(), function (array $unit) {
                return array_key_exists($unit['unitOfMeasurement'], self::$convertionMatrix);
            });
        }

        $variationUnit = $this->getUnitOfVariation($variation);

        if (null === $variationUnit) {
            return 1.0;
        }

        $modifier = self::$convertionMatrix[$variationUnit]['conversion'];

        $content = $variation['unit']['content'] * $modifier;

        if ($content <= 0.25 && 5 !== $variation['unit']['unitId'] && 2 !== $variation['unit']['unitId']) {
            return 0.1 / $modifier;
        }

        return 1.0 / $modifier;
    }
@param array $variation

@return float