S3Browser::formatSize PHP Method

formatSize() private static method

Takes a size in bytes and converts it to a more human-readable format
private static formatSize ( string $bytes ) : string
$bytes string Size in bytes
return string
    private static function formatSize($bytes)
    {
        $size = (int) $bytes;
        $units = array("B", "K", "M", "G", "T", "P");
        $unit = 0;
        while ($size >= 1024) {
            $unit++;
            $size = $size / 1024;
        }
        return number_format($size, $unit ? 2 : 0) . '' . $units[$unit];
    }