From 8f6e10e22f6b39141b386cb40483be3c89c20c8e Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 25 Dec 2006 23:20:53 +0000 Subject: [PATCH] Unifying the way we do singleton so we don't have to think about which method to use internally in these classes --- Functions.php | 16 ++++++++-------- Printer.php | 2 +- Register.php | 50 +++++++++++++++++++++++++------------------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Functions.php b/Functions.php index 59806eb..e1ed529 100644 --- a/Functions.php +++ b/Functions.php @@ -81,11 +81,11 @@ class BSFunctions * * @return object Shared instance */ - private function SharedInstance() + private function _Instance() { if (!self::$instance) { - self::$instance = new BSFunctions; + self::$instance = new BSFunctions(); } return self::$instance; } @@ -98,7 +98,7 @@ class BSFunctions */ public static function SetCookiePath($path) { - self::SharedInstance()->cookiePath = $path; + self::_Instance()->cookiePath = $path; } // ################################################################### @@ -109,7 +109,7 @@ class BSFunctions */ public static function SetCookieDomain($domain) { - self::SharedInstance()->cookieDomain = $domain; + self::_Instance()->cookieDomain = $domain; } // ################################################################### @@ -120,7 +120,7 @@ class BSFunctions */ public static function SetCookieTimeout($timeout) { - self::SharedInstance()->cookieTimeout = intval($timeout); + self::_Instance()->cookieTimeout = intval($timeout); } // ################################################################### @@ -136,7 +136,7 @@ class BSFunctions // expire the cookie if ($value === false) { - setcookie($name, $value, time() - (2 * self::SharedInstance()->cookieTimeout), self::SharedInstance()->cookiePath, self::SharedInstance()->cookieDomain); + setcookie($name, $value, time() - (2 * self::_Instance()->cookieTimeout), self::_Instance()->cookiePath, self::_Instance()->cookieDomain); } // set the cookie else @@ -147,10 +147,10 @@ class BSFunctions } else { - $expire = time() + self::SharedInstance()->cookieTimeout; + $expire = time() + self::_Instance()->cookieTimeout; } - setcookie($name, $value, $expire, self::SharedInstance()->cookiePath, self::SharedInstance()->cookieDomain); + setcookie($name, $value, $expire, self::_Instance()->cookiePath, self::_Instance()->cookieDomain); } } diff --git a/Printer.php b/Printer.php index ac2e403..945859d 100644 --- a/Printer.php +++ b/Printer.php @@ -81,7 +81,7 @@ class BSPrinter */ public static function _Instance() { - if (is_null(self::$instance)) + if (!self::$instance) { self::$instance = new BSPrinter(); } diff --git a/Register.php b/Register.php index 099e23f..f81c14e 100644 --- a/Register.php +++ b/Register.php @@ -137,9 +137,9 @@ class BSRegister * * @return object BSRegister instance */ - private static function Instance() + private static function _Instance() { - if (self::$instance == null) + if (!self::$instance) { self::$instance = new BSRegister(); set_error_handler(array(self::$instance, '_errorHandler')); @@ -155,7 +155,7 @@ class BSRegister */ public static function SetApplication($name) { - self::Instance()->application = $name; + self::_Instance()->application = $name; } // ################################################################### @@ -166,7 +166,7 @@ class BSRegister */ public static function GetApplication() { - return self::Instance()->application; + return self::_Instance()->application; } // ################################################################### @@ -177,7 +177,7 @@ class BSRegister */ public static function SetAppPath($path) { - self::Instance()->appPath = BSFunctions::FetchSourcePath($path); + self::_Instance()->appPath = BSFunctions::FetchSourcePath($path); } // ################################################################### @@ -188,7 +188,7 @@ class BSRegister */ public static function GetAppPath() { - return self::Instance()->appPath; + return self::_Instance()->appPath; } // ################################################################### @@ -199,7 +199,7 @@ class BSRegister */ public static function SetAppVersion($vers) { - self::Instance()->appVersion = $vers; + self::_Instance()->appVersion = $vers; } // ################################################################### @@ -210,7 +210,7 @@ class BSRegister */ public static function GetAppVersion() { - return self::Instance()->appVersion; + return self::_Instance()->appVersion; } // ################################################################### @@ -222,7 +222,7 @@ class BSRegister */ public static function SetWebPath($path) { - self::Instance()->webPath = BSFunctions::FetchSourcePath($path); + self::_Instance()->webPath = BSFunctions::FetchSourcePath($path); } // ################################################################### @@ -233,7 +233,7 @@ class BSRegister */ public static function GetWebPath() { - return self::Instance()->webPath; + return self::_Instance()->webPath; } // ################################################################### @@ -244,7 +244,7 @@ class BSRegister */ public static function SetDebug($debug) { - self::Instance()->debug = $debug; + self::_Instance()->debug = $debug; } // ################################################################### @@ -255,7 +255,7 @@ class BSRegister */ public static function GetDebug() { - return self::Instance()->debug; + return self::_Instance()->debug; } // ################################################################### @@ -268,13 +268,13 @@ class BSRegister */ public static function Register($key, $value) { - if (isset(self::Instance()->registry["$key"])) + if (isset(self::_Instance()->registry["$key"])) { trigger_error('Cannot overwrite a key in the registry'); return; } - self::Instance()->registry["$key"] = $value; + self::_Instance()->registry["$key"] = $value; } // ################################################################### @@ -286,13 +286,13 @@ class BSRegister */ public static function Unregister($key) { - if (!isset(self::Instance()->registry["$key"])) + if (!isset(self::_Instance()->registry["$key"])) { trigger_error('You cannot unregister a key that does not exist'); return; } - unset(self::Instance()->registry["$key"]); + unset(self::_Instance()->registry["$key"]); } // ################################################################### @@ -305,13 +305,13 @@ class BSRegister */ public static function Get($key) { - if (!isset(self::Instance()->registry["$key"])) + if (!isset(self::_Instance()->registry["$key"])) { trigger_error('Cannot access the registry with a non-existent key'); return; } - return self::Instance()->registry["$key"]; + return self::_Instance()->registry["$key"]; } // ################################################################### @@ -325,7 +325,7 @@ class BSRegister public static function GetType($class) { $class = 'BS' . $class; - foreach (self::Instance()->registry AS $key => $object) + foreach (self::_Instance()->registry AS $key => $object) { if ($object instanceof $class) { @@ -342,7 +342,7 @@ class BSRegister */ public static function GetAll() { - return self::Instance()->registry; + return self::_Instance()->registry; } // ################################################################### @@ -354,9 +354,9 @@ class BSRegister */ public static function Debug($msg) { - if (self::Instance()->debug) + if (self::_Instance()->debug) { - self::Instance()->debugInfo[] = $msg; + self::_Instance()->debugInfo[] = $msg; } } @@ -368,8 +368,8 @@ class BSRegister */ public static function GetDebugList() { - $output = ''; + foreach (self::_Instance()->debugInfo AS $notice) { $output .= ""; } @@ -447,7 +447,7 @@ class BSRegister echo "\n
\n"; echo "\n\n\t\n"; echo "\n\n\t\n"; - if ($stack AND self::Instance()->getDebug()) + if ($stack AND self::_Instance()->getDebug()) { echo "\n\n\t
$prefix: $title
$message
Debug Stack:
";
 			echo BSFunctions::FormatBacktrace(debug_backtrace());
-- 
2.22.5