protected function shorthandToBytes($shorthand)
{
if (is_numeric($shorthand)) {
// make sure that when float(1.234E17) is passed in, it doesn't get
// cast to string('1.234E17'), then to int(1)
return $shorthand;
}
$units = array('B' => 1024, 'M' => pow(1024, 2), 'G' => pow(1024, 3));
return (int) preg_replace_callback('/^([0-9]+)(' . implode(array_keys($units), '|') . ')$/', function ($match) use($units) {
return $match[1] * $units[$match[2]];
}, $shorthand);
}