Singleton::__clone()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Ffcms\Core\Traits;
4
5
/**
6
 * Class Singleton. Basic structure of singleton pattern.
7
 * @package Ffcms\Core\Traits
8
 */
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()
42
    {
43
    }
44
    final private function __clone()
45
    {
46
    }
47
}
48