public static function formatBytes($bytes)
    {
        $bytes = (double) abs($bytes);
        if ($bytes === 0.0) {
            return '0.00 B';
        }
        //units
        $units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB');
        $index = (int) (log($bytes)/log(1024));
        //echo $index;
        if ($index > 8) {
            throw new \OutOfRangeException('Input is to large! Maximum supported: 1.236731113465765645724418048 * 10^27 bytes.');
        }
        if ($index === 0) {
            //format
            $output = sprintf('%.2f %s', $bytes, $units[$index]);
        } else {
            //format
            $output = sprintf('%.2f %s', ($bytes/pow(1024, $index)), $units[$index]);
        }

        return $output;
    }