N°330 Improve \ormDocument::GetFormattedSize

* Fix typo in method name (many thanks @jbostoen !)
* Use \utils::BytesToFriendlyFormat
This commit is contained in:
Pierre Goiffon
2019-12-17 09:58:35 +01:00
parent d4dc739b30
commit 47d8e35639
5 changed files with 19 additions and 16 deletions

View File

@@ -591,18 +591,21 @@ class utils
* Format a value into a more friendly format (KB, MB, GB, TB) instead a juste a Bytes amount.
*
* @param float $value
* @param int $iPrecision
*
* @return string
*/
public static function BytesToFriendlyFormat($value)
public static function BytesToFriendlyFormat($value, $iPrecision = 0)
{
$sReturn = '';
$iPrecision = 0;
// Kilobytes
if ($value >= 1024)
{
$sReturn = 'K';
$value = $value / 1024;
$iPrecision = 1;
if ($iPrecision === 0) {
$iPrecision = 1;
}
}
// Megabytes
if ($value >= 1024)