Total Complexity | 5 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | abstract class Singleton implements Instantiatable |
||
19 | { |
||
20 | /** |
||
21 | * Все вызванные ранее инстансы классов |
||
22 | * |
||
23 | * @var array $instances |
||
24 | */ |
||
25 | private static $instances = []; |
||
26 | |||
27 | /** |
||
28 | * Singleton constructor. You can't create me |
||
29 | */ |
||
30 | private function __construct() |
||
31 | { |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @return Instantiatable|Singleton|static |
||
36 | */ |
||
37 | public static function me(): Instantiatable |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Функция получения инстанса класса |
||
44 | * |
||
45 | * @param string $class |
||
46 | * |
||
47 | * @return Singleton |
||
48 | */ |
||
49 | final public static function getInstance(string $class): Singleton |
||
57 | } |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * do not clone me |
||
62 | * @throws EntityException |
||
63 | */ |
||
64 | protected function __clone() |
||
69 |