You are here

private function MemoryDataCollector::convertToBytes in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-kernel/DataCollector/MemoryDataCollector.php \Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector::convertToBytes()
1 call to MemoryDataCollector::convertToBytes()
MemoryDataCollector::__construct in vendor/symfony/http-kernel/DataCollector/MemoryDataCollector.php

File

vendor/symfony/http-kernel/DataCollector/MemoryDataCollector.php, line 84

Class

MemoryDataCollector
MemoryDataCollector.

Namespace

Symfony\Component\HttpKernel\DataCollector

Code

private function convertToBytes($memoryLimit) {
  if ('-1' === $memoryLimit) {
    return -1;
  }
  $memoryLimit = strtolower($memoryLimit);
  $max = strtolower(ltrim($memoryLimit, '+'));
  if (0 === strpos($max, '0x')) {
    $max = intval($max, 16);
  }
  elseif (0 === strpos($max, '0')) {
    $max = intval($max, 8);
  }
  else {
    $max = (int) $max;
  }
  switch (substr($memoryLimit, -1)) {
    case 't':
      $max *= 1024;
    case 'g':
      $max *= 1024;
    case 'm':
      $max *= 1024;
    case 'k':
      $max *= 1024;
  }
  return $max;
}