From 1db26e419f41c52695aa5238a8a25c0517a4335f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 4 Jan 2009 19:33:13 -0800 Subject: [PATCH] There's no reason to make BSFunctions use a singleton. Switching it to be a purely-static class. * Functions.php: Made all the ivars static (BSFunctions::_instance): Removed (BSFunctions::set_cookie_path): Use new static ivar (BSFunctions::set_cookie_domain): ditto (BSFunctions::set_cookie_timeout): ditto (BSFunctions::cookie): ditto --- Functions.php | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/Functions.php b/Functions.php index 92195b5..8489a6c 100644 --- a/Functions.php +++ b/Functions.php @@ -28,8 +28,8 @@ /** * Functions * - * This is a bunch of static functions. This class is singleton so it - * can store data while remaining static. + * This is a bunch of static functions wrapped in a class for modularity and + * namespace collisions. * * @author Blue Static * @copyright Copyright (c)2005 - 2009, Blue Static @@ -38,29 +38,23 @@ */ class BSFunctions { - /** - * Singleton instance - * @var object - */ - private static $instance; - /** * Cookie path * @var string */ - private $cookiePath = '/'; + private static $cookiePath = '/'; /** * Cookie domain setting * @var string */ - private $cookieDomain = ''; + private static $cookieDomain = ''; /** * Cookie expiration time * @var integer */ - private $cookieTimeout = 900; + private static $cookieTimeout = 900; /** * Current swapped CSS class @@ -69,23 +63,10 @@ class BSFunctions public static $cssClass = ''; /** - * Constructor - */ - private function __construct() {} - - /** - * Returns the shared instance for singleton - * - * @return object Shared instance + * Make class static */ - private function _instance() - { - if (!self::$instance) - { - self::$instance = new BSFunctions(); - } - return self::$instance; - } + private function __construct() + {} /** * Sets the cookie path @@ -94,7 +75,7 @@ class BSFunctions */ public static function set_cookie_path($path) { - self::_instance()->cookiePath = $path; + self::$cookiePath = $path; } /** @@ -104,7 +85,7 @@ class BSFunctions */ public static function set_cookie_domain($domain) { - self::_instance()->cookieDomain = $domain; + self::$cookieDomain = $domain; } /** @@ -114,7 +95,7 @@ class BSFunctions */ public static function set_cookie_timeout($timeout) { - self::_instance()->cookieTimeout = intval($timeout); + self::$cookieTimeout = intval($timeout); } /** @@ -129,7 +110,7 @@ class BSFunctions // expire the cookie if ($value === false) { - setcookie($name, $value, time() - (2 * self::_instance()->cookieTimeout), self::_instance()->cookiePath, self::_instance()->cookieDomain); + setcookie($name, $value, time() - (2 * self::$cookieTimeout), self::$cookiePath, self::$cookieDomain); } // set the cookie else @@ -140,10 +121,10 @@ class BSFunctions } else { - $expire = time() + self::_instance()->cookieTimeout; + $expire = time() + self::$cookieTimeout; } - setcookie($name, $value, $expire, self::_instance()->cookiePath, self::_instance()->cookieDomain); + setcookie($name, $value, $expire, self::$cookiePath, self::$cookieDomain); } } -- 2.22.5