lithium\core\ErrorHandler::trace PHP Method

trace() public static method

Trim down a typical stack trace to class & method calls.
public static trace ( array $stack ) : array
$stack array A `debug_backtrace()`-compatible stack trace output.
return array Returns a flat stack array containing class and method references.
    public static function trace(array $stack)
    {
        $result = array();
        foreach ($stack as $frame) {
            if (isset($frame['function'])) {
                if (isset($frame['class'])) {
                    $result[] = trim($frame['class'], '\\') . '::' . $frame['function'];
                } else {
                    $result[] = $frame['function'];
                }
            }
        }
        return $result;
    }

Usage Example

 public function testTrace()
 {
     $current = debug_backtrace();
     $results = ErrorHandler::trace($current);
     $this->assertEqual(count($current), count($results));
     $this->assertEqual($results[0], 'lithium\\tests\\cases\\core\\ErrorHandlerTest::testTrace');
 }