StaticCallLog.php in X Autoload 7.5
File
tests/src/Util/StaticCallLog.php
View source
<?php
namespace Drupal\xautoload\Tests\Util;
abstract class StaticCallLog {
private static $callLog;
static function setCallLog(CallLog $callLog) {
if (isset(self::$callLog)) {
throw new \Exception("StaticCallLog already initialized.");
}
self::$callLog = $callLog;
}
static function unsetCallLog() {
if (!isset(self::$callLog)) {
throw new \Exception("StaticCallLog not initialized yet.");
}
self::$callLog = NULL;
}
static function addCall() {
if (!isset(self::$callLog)) {
throw new \Exception("StaticCallLog not initialized yet.");
}
$trace = version_compare(PHP_VERSION, '5.4.0', '>=') ? debug_backtrace(0, 2) : debug_backtrace(0);
$call = $trace[1];
$callFiltered = array();
foreach (array(
'function',
'class',
'type',
) as $key) {
if (isset($call[$key])) {
$callFiltered[$key] = $call[$key];
}
}
$callFiltered['args'] = array();
foreach ($call['args'] as $arg) {
if (is_array($arg)) {
$arg = '(array)';
}
elseif (is_object($arg)) {
$arg = '(' . get_class($arg) . ')';
}
$callFiltered['args'][] = $arg;
}
self::$callLog
->addCall($callFiltered);
}
}