Utilities/BinarySizeUtility.php
public static function format($size, $decimals = 2, $decPoint = '.', $thousandsSep = '', $unitSep = '')
    {
        $output = $unit = null;
        foreach (self::getBinarySizes() as $unit => $divider) {
            $output = $size / $divider;
            if ($output < 1000) {
                break;
            }
        }
        if (null === $output) {
            throw new \UnexpectedValueException("Unable to parse value: '{$size}'");
        }
        $unit = $unit === 'o' ? 'o' : ucfirst($unit);
        $trimmed = rtrim(rtrim(number_format($output, $decimals, $decPoint, $thousandsSep), '0'), $decPoint);
        $formatted = $trimmed.$unitSep.$unit;

        return str_replace(' ', utf8_encode(chr(160)), $formatted);
    }
public static function format($size, $decimals = 2, $decPoint = '.', $thousandsSep = '', $unitSep = '')
    {
        $output = $unit = null;
        foreach (self::getBinarySizes() as $unit => $divider) {
            $output = $size / $divider;
            if ($output < 1000) {
                break;
            }
        }
        if (null === $output) {
            throw new \UnexpectedValueException("Unable to parse value: '{$size}'");
        }
        $unit = $unit === 'o' ? 'o' : ucfirst($unit);
        $trimmed = rtrim(rtrim(number_format($output, $decimals, $decPoint, $thousandsSep), '0'), $decPoint);
        $formatted = $trimmed.$unitSep.$unit;

        return str_replace(' ', utf8_encode(chr(160)), $formatted);
    }
Return a binary size in a human readable form.

@param int    $size         number of octets
@param int    $decimals
@param string $decPoint
@param string $thousandsSep
@param string $unitSep

@throws \UnexpectedValueException

@return string