mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°330 Improve \ormDocument::GetFormattedSize
* Fix typo in method name (many thanks @jbostoen !) * Use \utils::BytesToFriendlyFormat
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user