1.  /**
  2.    * Gets the caller context (file name, line, function where the call originated), from a backtrace.
  3.    */
  4.   protected function getCallerContext($backtrace) {
  5.     // The first trace is the call itself.
  6.     // It gives us the line and the file of the call.
  7.     $call = $backtrace[0];
  8.    
  9.     // The second call give us the function where the call originated.
  10.     if (isset($backtrace[1])) {
  11.       if (isset($backtrace[1]['class'])) {
  12.         $call['function'] = $backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . '()';
  13.       }
  14.       else {
  15.         $call['function'] = $backtrace[1]['function'] . '()';
  16.       }
  17.     }
  18.     else {
  19.       $call['function'] = 'main()';
  20.     }
  21.   }