Back to FilesystemHelper class

Method parseSizeUnit

private static string
parseSizeUnit
(mixed $maxSize)
Creates the rounded size of the size with the appropriate unit
Parameters
  • float $maxSize The maximum size which is allowed for the uploads
Returns
  • string String with the size and the appropriate unit
Since
  • 3.4

Method parseSizeUnit - Source code

/**
 * Creates the rounded size of the size with the appropriate unit
 *
 * @param   float  $maxSize  The maximum size which is allowed for the uploads
 *
 * @return  string String with the size and the appropriate unit
 *
 * @since   3.4
 */
private static function parseSizeUnit($maxSize)
{
    $base = log($maxSize) / log(1024);
    $suffixes = array('', 'k', 'M', 'G', 'T');
    return round(pow(1024, $base - floor($base)), 0) . $suffixes[floor($base)];
}