Bocharsky Victor
2014-12-19 11:09:40 +02:00
parent 0ecfd9f4f3
commit 0f6709c751

View File

@@ -72,21 +72,23 @@ one instance of a particular class. The singleton pattern enables us to do this.
<?php <?php
class Singleton class Singleton
{ {
/**
* @static Singleton The reference to *Singleton* instance of this class
*/
private static $instance;
/** /**
* Returns the *Singleton* instance of this class. * Returns the *Singleton* instance of this class.
* *
* @staticvar Singleton $instance The *Singleton* instances of this class.
*
* @return Singleton The *Singleton* instance. * @return Singleton The *Singleton* instance.
*/ */
public static function getInstance() public static function getInstance()
{ {
static $instance = null; if (null === static::$instance) {
if (null === $instance) { static::$instance = new static();
$instance = new static();
} }
return $instance; return static::$instance;
} }
/** /**