function DrupalDataCollectorTrait::convertToBytes
Parameters
$value:
Return value
int|string
File
-
webprofiler/
src/ DataCollector/ DrupalDataCollectorTrait.php, line 83
Class
- DrupalDataCollectorTrait
- Class DrupalDataCollectorTrait
Namespace
Drupal\webprofiler\DataCollectorCode
private function convertToBytes($value) {
if ('-1' === $value) {
return -1;
}
$value = strtolower($value);
$max = strtolower(ltrim($value, '+'));
if (0 === strpos($max, '0x')) {
$max = intval($max, 16);
}
elseif (0 === strpos($max, '0')) {
$max = intval($max, 8);
}
else {
$max = intval($max);
}
switch (substr($value, -1)) {
case 't':
$max *= 1024;
break;
case 'g':
$max *= 1024;
break;
case 'm':
$max *= 1024;
break;
case 'k':
$max *= 1024;
break;
}
return $max;
}