private static function roundHalfToEven($amount)
    {
        $result = self::roundToNearestIntegerIgnoringTies($amount);

        if (null == $result) {
            $truncated = self::roundHalfTowardsZero($amount);

            if (0 == bcmod($truncated, '2')) { // Even
                $result = $truncated;
            } else {
                $result = self::roundHalfAwayFromZero($amount);
            }
        }

        return $result;
    }
private static function roundHalfToEven($amount)
    {
        $result = self::roundToNearestIntegerIgnoringTies($amount);

        if (null == $result) {
            $truncated = self::roundHalfTowardsZero($amount);

            if (0 == bcmod($truncated, '2')) { // Even
                $result = $truncated;
            } else {
                $result = self::roundHalfAwayFromZero($amount);
            }
        }

        return $result;
    }
private static function roundHalfToEven ( $ amount ) { $ result = self :: roundToNearestIntegerIgnoringTies ( $ amount ) ; if ( null == $ result ) { $ truncated = self :: roundHalfTowardsZero ( $ amount ) ; if ( 0 == bcmod ( $ truncated , '2' ) ) { // Even $ result = $ truncated ; } else { $ result = self :: roundHalfAwayFromZero ( $ amount ) ; } } return $ result ; }
If the fraction of the amount is 0.5, then return the even integer nearest to the amount.

@param string $amount the amount to round

@return string
If the fraction of the amount is 0 . 5 then return the even integer nearest to the amount .