| 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() |
|
| 48 | |||
| 49 | /** |
||
| 50 | * Initialization of class instance |
||
| 51 | * |
||
| 52 | * @return static |
||
| 53 | */ |
||
| 54 | 1 | protected static function initInstance() |
|
| 58 | |||
| 59 | /** |
||
| 60 | * Disabled by access level |
||
| 61 | */ |
||
| 62 | 1 | protected function __construct() |
|
| 65 | |||
| 66 | /** |
||
| 67 | * Disabled by access level |
||
| 68 | */ |
||
| 69 | protected function __clone() |
||
| 72 | } |
||
| 73 |