1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106:
<?php
class ExceptionUtils
{
public static function get_file($call)
{
if (!empty($call['file']))
{
return Path::get_path_from_root($call['file']);
}
return 'Internal';
}
public static function get_line($call)
{
if (!empty($call['file']))
{
return $call['line'];
}
return '';
}
public static function get_method_prototype($call)
{
$prototype = '';
if (!empty($call['class']))
{
$prototype .= $call['class'] . $call['type'];
}
$prototype .= $call['function'] . '(';
$prototype .= implode(', ', self::get_args_types($call));
$prototype .= ')';
return $prototype;
}
public static function has_args($call)
{
return !empty($call['args']);
}
private static function get_args_types($call)
{
$types = array();
if (empty($call['args']))
{
return $types;
}
foreach ($call['args'] as $arg)
{
$types[] = self::get_arg_type($arg);
}
return $types;
}
public static function get_arg_type($arg)
{
if (is_array($arg))
{
return 'array';
}
elseif (is_bool($arg))
{
return 'boolean';
}
elseif (is_int($arg))
{
return 'int';
}
elseif (is_float($arg))
{
return 'float';
}
elseif (is_string($arg))
{
return 'string';
}
elseif (is_object($arg))
{
return get_class($arg);
}
return 'null';
}
public static function get_args($call)
{
$args = $call['args'];
$trace = '<ul>';
foreach ($args as $arg)
{
$trace .= '<li><pre>' . TextHelper::htmlspecialchars(print_r($arg, true)) . '</pre></li>';
}
$trace .= '</ul>';
return $trace;
}
}
?>