Back to FilesystemHelper class

Method parseSize

private static float
parseSize
(mixed $size)
Returns the size in bytes without the unit for the comparison
Parameters
  • string $size The size which is received from the PHP settings
Returns
  • float The size in bytes without the unit
Since
  • 3.4

Method parseSize - Source code

/**
 * Returns the size in bytes without the unit for the comparison
 *
 * @param   string  $size  The size which is received from the PHP settings
 *
 * @return  float The size in bytes without the unit
 *
 * @since   3.4
 */
private static function parseSize($size)
{
    $unit = preg_replace('/[^bkmgtpezy]/i', '', $size);
    $size = preg_replace('/[^0-9\\.]/', '', $size);
    $return = round($size);
    if ($unit) {
        $return = round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
    }
    return $return;
}
OSZAR »