@@ -16,13 +16,13 @@ |
||
| 16 | 16 | |
| 17 | 17 | public static function getInstance() |
| 18 | 18 | { |
| 19 | - static $instances; |
|
| 19 | + static $instances; |
|
| 20 | 20 | |
| 21 | - $calledClass = get_called_class(); |
|
| 21 | + $calledClass = get_called_class(); |
|
| 22 | 22 | |
| 23 | 23 | if (!isset($instances[$calledClass])) |
| 24 | 24 | { |
| 25 | - $instances[$calledClass] = new $calledClass(); |
|
| 25 | + $instances[$calledClass] = new $calledClass(); |
|
| 26 | 26 | } |
| 27 | 27 | return $instances[$calledClass]; |
| 28 | 28 | } |
@@ -4,19 +4,19 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Example |
| 6 | 6 | { |
| 7 | - use \ByJG\DesignPattern\Singleton; |
|
| 7 | + use \ByJG\DesignPattern\Singleton; |
|
| 8 | 8 | |
| 9 | - protected $_uniqId; |
|
| 9 | + protected $_uniqId; |
|
| 10 | 10 | |
| 11 | - protected function __construct() |
|
| 12 | - { |
|
| 13 | - $this->_uniqId = rand(0, 1000); |
|
| 14 | - } |
|
| 11 | + protected function __construct() |
|
| 12 | + { |
|
| 13 | + $this->_uniqId = rand(0, 1000); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public function getId() |
|
| 17 | - { |
|
| 18 | - return $this->_uniqId; |
|
| 19 | - } |
|
| 16 | + public function getId() |
|
| 17 | + { |
|
| 18 | + return $this->_uniqId; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |