private function DrupalDataCollectorTrait::convertToBytes in Devel 8.2
Same name and namespace in other branches
- 8.3 webprofiler/src/DataCollector/DrupalDataCollectorTrait.php \Drupal\webprofiler\DataCollector\DrupalDataCollectorTrait::convertToBytes()
- 8 webprofiler/src/DataCollector/DrupalDataCollectorTrait.php \Drupal\webprofiler\DataCollector\DrupalDataCollectorTrait::convertToBytes()
- 4.x webprofiler/src/DataCollector/DrupalDataCollectorTrait.php \Drupal\webprofiler\DataCollector\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;
}