@@ -4,31 +4,31 @@ |
||
4 | 4 | |
5 | 5 | trait Singleton |
6 | 6 | { |
7 | - protected function __construct() |
|
8 | - { |
|
9 | - } |
|
7 | + protected function __construct() |
|
8 | + { |
|
9 | + } |
|
10 | 10 | |
11 | - /** |
|
12 | - * @throws SingletonException |
|
13 | - */ |
|
14 | - final private function __clone() |
|
15 | - { |
|
16 | - throw new SingletonException('You can not clone a singleton.'); |
|
17 | - } |
|
11 | + /** |
|
12 | + * @throws SingletonException |
|
13 | + */ |
|
14 | + final private function __clone() |
|
15 | + { |
|
16 | + throw new SingletonException('You can not clone a singleton.'); |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * @return static |
|
21 | - */ |
|
22 | - public static function getInstance() |
|
23 | - { |
|
24 | - static $instances; |
|
19 | + /** |
|
20 | + * @return static |
|
21 | + */ |
|
22 | + public static function getInstance() |
|
23 | + { |
|
24 | + static $instances; |
|
25 | 25 | |
26 | - $calledClass = get_called_class(); |
|
26 | + $calledClass = get_called_class(); |
|
27 | 27 | |
28 | - if (!isset($instances[$calledClass])) { |
|
29 | - $instances[$calledClass] = new $calledClass(); |
|
30 | - } |
|
31 | - return $instances[$calledClass]; |
|
32 | - } |
|
28 | + if (!isset($instances[$calledClass])) { |
|
29 | + $instances[$calledClass] = new $calledClass(); |
|
30 | + } |
|
31 | + return $instances[$calledClass]; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | } |