';
var_dump($output);
echo '';
} else {
error_log(var_dump($output));
}
exit();
}
/**
* On true evaluation show output and exit script.
* @param unknown $evaluation
* @param array|string $output
*/
static public function dieIf($evaluation, $output)
{
if ($evaluation) {
self::dieWith($output);
}
}
/**
* Log something.
* @param string $label
* @param array|string $output
*/
static public function log($label, $output)
{
if ('html' == self::$mode) {
echo "$label:
";
echo '
'; var_dump($output); echo ''; } else { error_log("$label:"); error_log(print_r($output, true)); } } /** * Log to php error log. * @param string $label * @param array|string $output */ static public function errorLog($label, $output) { error_log("$label: ".print_r($output, true)); } /** * Recursively strip doctrine entities from stacked array. * @param array $data * @return array */ static public function stripEntities(array $data) { foreach ($data as $key => $value) { if (is_object($value) && strpos(get_class($value), 'Entity') !== false) { $data[$key] = self::stripEntities($value->toArray()); } if (is_array($value)) { $data[$key] = self::stripEntities($value); } } return $data; } /** * Log to php error log with doctrine entities stripped to arrays. * @param string $label * @param array|string $output */ static public function errorLogStripped($label, $output) { if (is_object($output) && strpos(get_class($output), 'Entity') !== false) { $output = $output->toArray(); } if (is_array($output)) { foreach ($output as $key => $value) { if (is_object($value) && strpos(get_class($value), 'Entity') !== false) { $output[$key] = self::stripEntities($value->toArray()); } if (is_array($value)) { $output[$key] = self::stripEntities($value); } } } error_log("$label: ".print_r($output, true)); } /** * Log a debug backtrace to php error log. */ static public function logBacktrace() { error_log(print_r(debug_backtrace(), true)); } /** * Output php array as html table. * @param array $array * @param string $title * @return string */ static public function arrayToTable(array $array, $title = null) { $html = '
' . htmlentities($title) . ' | |
---|---|
" . htmlentities($key) . ": | " . $val . " | "; $html .= '