Example #1
0
 /**
  * __toString alias
  *
  * @return string $dump
  */
 public function toString()
 {
     return Doctrine::dump(get_object_vars($this));
 }
Example #2
0
 /**
  * Generates a string representation of a collection.
  *
  * This method returns an html dump of a collection of records, containing 
  * all data.
  *
  * @param Doctrine_Collection $collection
  * @return string
  */
 public static function getCollectionAsString(Doctrine_Collection $collection)
 {
     $r[] = "<pre>";
     $r[] = get_class($collection);
     $r[] = 'data : ' . Doctrine::dump($collection->getData(), false);
     //$r[] = 'snapshot : ' . Doctrine::dump($collection->getSnapshot());
     $r[] = "</pre>";
     return implode("\n", $r);
 }
Example #3
0
 /**
  * dump
  *
  * dumps a given variable
  *
  * @param mixed $var        a variable of any type
  * @param boolean $output   whether to output the content
  * @return void|string
  */
 public static function dump($var, $output = true)
 {
     $ret = array();
     switch (gettype($var)) {
         case 'array':
             $ret[] = 'Array(';
             foreach ($var as $k => $v) {
                 $ret[] = $k . ' : ' . Doctrine::dump($v, false);
             }
             $ret[] = ")";
             break;
         case 'object':
             $ret[] = 'Object(' . get_class($var) . ')';
             break;
         default:
             $ret[] = var_export($var, true);
     }
     if ($output) {
         print implode("\n", $ret);
     }
     return implode("\n", $ret);
 }