Gush\Helper\DownloadHelper::formatSize PHP Метод

formatSize() приватный Метод

Utility method to show the number of bytes in a readable format.
private formatSize ( integer $bytes ) : string
$bytes integer The number of bytes to format.
Результат string The human readable string of bytes (e.g. 4.32MB).
    private function formatSize($bytes)
    {
        $units = ['B', 'KB', 'MB', 'GB', 'TB'];
        $bytes = max($bytes, 0);
        $pow = $bytes ? floor(log($bytes, 1024)) : 0;
        $pow = min($pow, count($units) - 1);
        $bytes /= pow(1024, $pow);
        return number_format($bytes, 2) . ' ' . $units[$pow];
    }