BackupManager\Laravel\DbListCommand::formatBytes PHP 메소드

formatBytes() 개인적인 메소드

private formatBytes ( $bytes, integer $precision = 2 ) : string
$bytes
$precision integer
리턴 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];
    }