You are here

static function StaticCallLog::addCall in X Autoload 7.5

called from stream wrapper code in

Throws

\Exception

See also

ExampleModules::setupExampleModuleFiles()

File

tests/src/Util/StaticCallLog.php, line 44

Class

StaticCallLog

Namespace

Drupal\xautoload\Tests\Util

Code

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);
}