From 9f42b875754723eee1e706ea11b0e908b1fbb4ea Mon Sep 17 00:00:00 2001 From: zYne Date: Sat, 17 Feb 2007 10:35:45 +0000 Subject: [PATCH] added dump() method --- lib/Doctrine.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/Doctrine.php b/lib/Doctrine.php index 281508806..2c78a061c 100644 --- a/lib/Doctrine.php +++ b/lib/Doctrine.php @@ -453,6 +453,33 @@ final class Doctrine return true; } + /** + * dump + * + * dumps a given variable + * + * @param mixed $var a variable of any type + * @return void|string + */ + public static function dump($var) + { + $ret = array(); + switch (gettype($var)) { + case 'array': + $ret[] = 'Array('; + foreach ($var as $k => $v) { + $ret[] = $k . ' : ' . Doctrine::dump($v); + } + $ret[] = ')'; + break; + case 'object'; + $ret[] = 'Object(' . get_class($var) . ')'; + break; + default: + $ret[] = var_export($var, true); + } + return implode("\n", $ret); + } /** * returns table name from class name *