* @license PHP License * @package WB * @subpackage base */ /** * StdClass * * Very basic class. * * @version 0.2.3 * @package WB * @subpackage base */ class WBStdClass { /** * my object id * @var string */ private $myObjectId = null; /** * Current Debug Logger * @var WBLog */ private $myDebugLogger = null; /** * to String * * @return string */ public function __toString() { return $this->getObjectId(); } /** * receive unique id of this object * * Loves to use {@link spl_object_hash()} but also provides a * workaround using class name and counter. * * @return string onject id */ public function getObjectId() { // return cached object id if ($this->myObjectId) { return $this->myObjectId; } // use SPL function to receive object id if (function_exists('spl_object_hash')) { $this->myObjectId = spl_object_hash($this); return $this->myObjectId; } } /** * Debug Print * * Auxiliary function to print debug messages on stdout * * @param mixed something to print * @param int minimum debug level to print */ protected function debugPrint($out, $level = 1) { if (WBParam::get('wb/debug', 0) < $level) { return; } if (empty($this->myDebugLogger)) { WBClass::load('WBLog'); $this->myDebugLogger = WBLog::start('debug'); } $clazz = get_class($this); if (!is_scalar($out)) { $out = print_r($out, true); } $this->myDebugLogger->debug($clazz . ' ' . trim($out)); } }