BackupManager\Laravel\DbListCommand::formatBytes PHP Method

formatBytes() private method

private formatBytes ( $bytes, integer $precision = 2 ) : string
$bytes
$precision integer
return string
    private function formatBytes($bytes, $precision = 2)
    {
        $units = ['B', 'KB', 'MB', 'GB', 'TB'];
        $bytes = max($bytes, 0);
        $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
        $pow = min($pow, count($units) - 1);
        return round($bytes, $precision) . ' ' . $units[$pow];
    }