public static function niceSize($size)
{
// file mode
if (is_string($size) && file_exists($size)) {
$size = static::size($size);
}
// make sure it's an int
$size = (int) $size;
// avoid errors for invalid sizes
if ($size <= 0) {
return '0 kB';
}
// the math magic
return round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . static::$units[$i];
}