Merge pull request #13 from Ti-webdev/master

Move Singleton::$_instance into Singleton::getInstance() method
This commit is contained in:
Dominik Liebler
2013-05-17 14:14:42 -07:00

View File

@@ -16,11 +16,6 @@ namespace DesignPatterns;
*/ */
class Singleton class Singleton
{ {
/**
* @var \DesignPatterns\Singleton
*/
private static $_instance;
/** /**
* gets the instance via lazy initialization (created on first usage) * gets the instance via lazy initialization (created on first usage)
* *
@@ -28,11 +23,13 @@ class Singleton
*/ */
public static function getInstance() public static function getInstance()
{ {
if (null === self::$_instance) { static $instance;
self::$_instance = new self();
if (null === $instance) {
$instance = new self();
} }
return self::$_instance; return $instance;
} }
/** /**