| 1 | <?php |
||
| 21 | trait Singleton |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * @var static singleton instance |
||
| 25 | */ |
||
| 26 | protected static $instance; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Set or replace instance |
||
| 30 | * |
||
| 31 | * @param mixed $instance |
||
| 32 | * @return void |
||
| 33 | */ |
||
| 34 | 630 | public static function setInstance($instance) |
|
| 38 | |||
| 39 | /** |
||
| 40 | * Get instance |
||
| 41 | * |
||
| 42 | * @return static |
||
| 43 | */ |
||
| 44 | 653 | public static function getInstance() |
|
| 50 | |||
| 51 | /** |
||
| 52 | * Initialization of class instance |
||
| 53 | * |
||
| 54 | * @return static |
||
| 55 | */ |
||
| 56 | 1 | protected static function initInstance() |
|
| 60 | |||
| 61 | /** |
||
| 62 | * Disabled by access level |
||
| 63 | */ |
||
| 64 | 1 | protected function __construct() |
|
| 67 | |||
| 68 | /** |
||
| 69 | * Disabled by access level |
||
| 70 | */ |
||
| 71 | protected function __clone() |
||
| 74 | } |
||
| 75 |