CodeSniffer initial steps
This commit is contained in:
@ -16,15 +16,16 @@ class AppExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $bytes
|
||||
* @param int $precision
|
||||
* @return string
|
||||
* Format a file size to be human readable
|
||||
* @param int $bytes Number of bytes
|
||||
* @param int $precision Precision
|
||||
* @return string Formatted string
|
||||
*/
|
||||
public function formatBytes($bytes, $precision = 2)
|
||||
{
|
||||
$size = ['B','kB','MB','GB','TB','PB','EB','ZB','YB'];
|
||||
$factor = floor((strlen($bytes) - 1) / 3);
|
||||
return sprintf("%.{$precision}f", $bytes / pow(1024, $factor)) . @$size[$factor];
|
||||
$fact = floor((strlen($bytes) - 1) / 3);
|
||||
return sprintf("%.{$precision}f", $bytes / pow(1024, $fact)) . $size[$fact];
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user