DrupalDataCollectorTrait.php in Devel 8.2
File
webprofiler/src/DataCollector/DrupalDataCollectorTrait.php
View source
<?php
namespace Drupal\webprofiler\DataCollector;
trait DrupalDataCollectorTrait {
public function reset() {
$this->data = array();
}
public function getPanelSummary() {
return NULL;
}
public function hasPanel() {
return TRUE;
}
public function getLibraries() {
return [];
}
public function getDrupalSettings() {
return [];
}
public function getData() {
return $this->data;
}
public function getMethodData($class, $method) {
$class = is_object($class) ? get_class($class) : $class;
$data = [];
try {
$reflectedMethod = new \ReflectionMethod($class, $method);
$data = [
'class' => $class,
'method' => $method,
'file' => $reflectedMethod
->getFilename(),
'line' => $reflectedMethod
->getStartLine(),
];
} catch (\ReflectionException $re) {
} finally {
return $data;
}
}
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;
}
}