src/TreeHouse/Feeder/Modifier/Data/Transformer/LocalizedStringToNumberTransformer.php
private function round($number)
    {
        if (null !== $this->precision && null !== $this->roundingMode) {
            // shift number to maintain the correct precision during rounding
            $roundingCoef = pow(10, $this->precision);
            $number *= $roundingCoef;

            switch ($this->roundingMode) {
                case \NumberFormatter::ROUND_CEILING:
                    $number = ceil($number);
                    break;
                case \NumberFormatter::ROUND_FLOOR:
                    $number = floor($number);
                    break;
                case \NumberFormatter::ROUND_UP:
                    $number = $number > 0 ? ceil($number) : floor($number);
                    break;
                case \NumberFormatter::ROUND_DOWN:
                    $number = $number > 0 ? floor($number) : ceil($number);
                    break;
                case \NumberFormatter::ROUND_HALFEVEN:
                    $number = round($number, 0, PHP_ROUND_HALF_EVEN);
                    break;
                case \NumberFormatter::ROUND_HALFUP:
                    $number = round($number, 0, PHP_ROUND_HALF_UP);
                    break;
                case \NumberFormatter::ROUND_HALFDOWN:
                    $number = round($number, 0, PHP_ROUND_HALF_DOWN);
                    break;
            }

            $number /= $roundingCoef;
        }

        return $number;
    }
private function round($number)
    {
        if (null !== $this->precision && null !== $this->roundingMode) {
            // shift number to maintain the correct precision during rounding
            $roundingCoef = pow(10, $this->precision);
            $number *= $roundingCoef;

            switch ($this->roundingMode) {
                case \NumberFormatter::ROUND_CEILING:
                    $number = ceil($number);
                    break;
                case \NumberFormatter::ROUND_FLOOR:
                    $number = floor($number);
                    break;
                case \NumberFormatter::ROUND_UP:
                    $number = $number > 0 ? ceil($number) : floor($number);
                    break;
                case \NumberFormatter::ROUND_DOWN:
                    $number = $number > 0 ? floor($number) : ceil($number);
                    break;
                case \NumberFormatter::ROUND_HALFEVEN:
                    $number = round($number, 0, PHP_ROUND_HALF_EVEN);
                    break;
                case \NumberFormatter::ROUND_HALFUP:
                    $number = round($number, 0, PHP_ROUND_HALF_UP);
                    break;
                case \NumberFormatter::ROUND_HALFDOWN:
                    $number = round($number, 0, PHP_ROUND_HALF_DOWN);
                    break;
            }

            $number /= $roundingCoef;
        }

        return $number;
    }
private function round ( $ number ) { if ( null !== $ this -> precision && null !== $ this -> roundingMode ) { // shift number to maintain the correct precision during rounding $ roundingCoef = pow ( 10 , $ this -> precision ) ; $ number *= $ roundingCoef ; switch ( $ this -> roundingMode ) { case \ NumberFormatter :: ROUND_CEILING : $ number = ceil ( $ number ) ; break ; case \ NumberFormatter :: ROUND_FLOOR : $ number = floor ( $ number ) ; break ; case \ NumberFormatter :: ROUND_UP : $ number = $ number > 0 ? ceil ( $ number ) : floor ( $ number ) ; break ; case \ NumberFormatter :: ROUND_DOWN : $ number = $ number > 0 ? floor ( $ number ) : ceil ( $ number ) ; break ; case \ NumberFormatter :: ROUND_HALFEVEN : $ number = round ( $ number , 0 , PHP_ROUND_HALF_EVEN ) ; break ; case \ NumberFormatter :: ROUND_HALFUP : $ number = round ( $ number , 0 , PHP_ROUND_HALF_UP ) ; break ; case \ NumberFormatter :: ROUND_HALFDOWN : $ number = round ( $ number , 0 , PHP_ROUND_HALF_DOWN ) ; break ; } $ number /= $ roundingCoef ; } return $ number ; }
Rounds a number according to the configured precision and rounding mode.

@param int|float $number A number.

@return int|float The rounded number.
Rounds a number according to the configured precision and rounding mode .