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

@@ -85,18 +85,16 @@ class ormDocument
return strlen($this->m_data);
}
public function GetFormatedSize($precision = 2)
/**
* @param int $precision
*
* @return string
* @uses utils::BytesToFriendlyFormat()
*/
public function GetFormattedSize($precision = 2)
{
$bytes = $this->GetSize();
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision).' '.$units[$pow];
return utils::BytesToFriendlyFormat($bytes, $precision);
}
public function GetData()
{