mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-09-25 22:09:23 +02:00
Applied fixes from StyleCI
This commit is contained in:
committed by
StyleCI Bot
parent
3663603b80
commit
fe1f144ec3
@@ -2,10 +2,8 @@
|
||||
|
||||
namespace DesignPatterns\Creational\Singleton;
|
||||
|
||||
use DesignPatterns\Creational\Singleton\SingletonPatternViolationException;
|
||||
|
||||
/**
|
||||
* class Singleton
|
||||
* class Singleton.
|
||||
*/
|
||||
class Singleton
|
||||
{
|
||||
@@ -13,16 +11,16 @@ class Singleton
|
||||
* @var Singleton reference to singleton instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
|
||||
/**
|
||||
* gets the instance via lazy initialization (created on first usage)
|
||||
* gets the instance via lazy initialization (created on first usage).
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (null === static::$instance) {
|
||||
static::$instance = new static;
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
@@ -30,28 +28,31 @@ class Singleton
|
||||
|
||||
/**
|
||||
* is not allowed to call from outside: private!
|
||||
*
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* prevent the instance from being cloned
|
||||
* prevent the instance from being cloned.
|
||||
*
|
||||
* @throws SingletonPatternViolationException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public final function __clone()
|
||||
final public function __clone()
|
||||
{
|
||||
throw new SingletonPatternViolationException('This is a Singleton. Clone is forbidden');
|
||||
}
|
||||
|
||||
/**
|
||||
* prevent from being unserialized
|
||||
* prevent from being unserialized.
|
||||
*
|
||||
* @throws SingletonPatternViolationException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public final function __wakeup()
|
||||
final public function __wakeup()
|
||||
{
|
||||
throw new SingletonPatternViolationException('This is a Singleton. __wakeup usage is forbidden');
|
||||
}
|
||||
|
Reference in New Issue
Block a user