Gumbo_Interface_Singleton



Singleton Pattern Interface

The Singleton Design Pattern ensures that only one object of the class is instantiated during runtime. The static method checks if an object has been created. If the reference is null, it creates a new object using the private Constructor.

Requirements:

  • private static property to hold single object reference
  • private constructor
Typical Implementation:
 private static $_instance = null;
 private function __construct () {}
 public static function instance () {
 	if (self::$_instance == null) {
 		self::$_instance = new MyClassName ();
 	}
 	return self::$_instance;
 }

Author(s): Michael Luster <mluster79@yahoo.com>
License:New BSD License
Copyright:Copyright (c) 2007, iBayou, Michael Luster
Link:http://sourceforge.net/projects/phpgumbo
Version:0.0.1

Interface Methods

public static Gumbo_Interface_Singleton instance ( ) [line 60]

Returns an instance of the class


[ Top ]