| Total Complexity | 7 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | trait Singleton |
||
| 10 | { |
||
| 11 | protected static $instance; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @return static |
||
| 15 | */ |
||
| 16 | final public static function instance() |
||
| 17 | { |
||
| 18 | if (!isset(static::$instance)) { |
||
| 19 | static::$instance = new static; |
||
| 20 | static::boot(); |
||
| 21 | } |
||
| 22 | return static::$instance; |
||
| 23 | } |
||
| 24 | |||
| 25 | public static function boot() |
||
| 26 | { |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Override constructor |
||
| 31 | */ |
||
| 32 | final private function __construct() |
||
| 33 | { |
||
| 34 | $this->init(); |
||
| 35 | } |
||
| 36 | |||
| 37 | // disable some magic |
||
| 38 | protected function init() |
||
| 39 | { |
||
| 40 | } |
||
| 41 | final private function __wakeup() |
||
| 43 | } |
||
| 44 | final private function __clone() |
||
| 46 | } |
||
| 47 | } |
||
| 48 |