private function MemoryDataCollector::convertToBytes

1 call to MemoryDataCollector::convertToBytes()
MemoryDataCollector::__construct in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php, line 76

Class

MemoryDataCollector
MemoryDataCollector.

Namespace

Symfony\Component\HttpKernel\DataCollector

Code

private function convertToBytes($memoryLimit) {
  if ('-1' === $memoryLimit) {
    return -1;
  }
  if (preg_match('#^\\+?(0x?)?(.*?)([kmg]?)$#', $memoryLimit, $match)) {
    $shifts = array(
      '' => 0,
      'k' => 10,
      'm' => 20,
      'g' => 30,
    );
    $bases = array(
      '' => 10,
      '0' => 8,
      '0x' => 16,
    );
    return intval($match[2], $bases[$match[1]]) << $shifts[$match[3]];
  }
  return 0;
}