Joli\GifExceptionBundle\Command\GifOptimizerCommand::formatBytes PHP Method

formatBytes() private method

private formatBytes ( $bytes, boolean $useStandard = true ) : string
$bytes
$useStandard boolean
return string
    private function formatBytes($bytes, $useStandard = true)
    {
        $unit = $useStandard ? 1024 : 1000;
        if ($bytes <= $unit) {
            return $bytes . " B";
        }
        $exp = intval(log($bytes) / log($unit));
        $pre = $useStandard ? "kMGTPE" : "KMGTPE";
        $pre = $pre[$exp - 1] . ($useStandard ? "" : "i");
        return sprintf("%.1f %sB", $bytes / pow($unit, $exp), $pre);
    }