Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Singleton Snippet
class ${ClassName} {
protected static $instance;
/**
* Returns an instance of this Singleton
* @return ${ClassName}
*/
public static function getInstance() {
if(!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
protected function __construct() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.