GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( e4173a...96bf27 )
by Steeven
15:39
created

AbstractSingleton   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 9
dl 0
loc 74
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __clone() 0 2 1
A __construct() 0 3 1
A getInstance() 0 13 3
A __wakeup() 0 2 1
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Spl\Patterns\Creational\Singleton;
15
16
/**
17
 * Class AbstractSingleton
18
 * @package O2System\Spl\Patterns\Creational\Singleton
19
 */
20
class AbstractSingleton implements InstanceInterface
21
{
22
    /**
23
     * AbstractSingleton::$instance
24
     *
25
     * Singleton Instance
26
     *
27
     * @var static
28
     */
29
    protected static $instance;
30
31
    // ------------------------------------------------------------------------
32
33
    /**
34
     * AbstractSingleton::__construct
35
     *
36
     * Protected constructor to prevent creating a new instance of the
37
     * *Singleton* via the `new` operator from outside of this class.
38
     */
39
    protected function __construct()
40
    {
41
        static::$instance =& $this;
42
    }
43
44
    // ------------------------------------------------------------------------
45
46
    /**
47
     * AbstractSingleton::getInstance
48
     *
49
     * Returns the *Singleton* instance of this class.
50
     *
51
     * @return static Returns the instance class
52
     */
53
    public static function getInstance()
54
    {
55
        if (empty(static::$instance)) {
56
            $className = get_called_class();
57
58
            static::$instance = new $className();
59
60
            if (method_exists(static::$instance, '__reconstruct')) {
61
                call_user_func_array([&static::$instance, '__reconstruct'], func_get_args());
62
            }
63
        }
64
65
        return static::$instance;
0 ignored issues
show
Bug Best Practice introduced by
The expression return static::instance also could return the type object which is incompatible with the return type mandated by O2System\Spl\Patterns\Cr...nterface::getInstance() of object.
Loading history...
66
    }
67
68
    // ------------------------------------------------------------------------
69
70
    /**
71
     * AbstractSingleton::__clone
72
     *
73
     * Application of __clone magic method with private visibility to prevent cloning of
74
     * the *Singleton* instance.
75
     *
76
     * @return void
77
     */
78
    protected function __clone()
79
    {
80
    }
81
82
    // ------------------------------------------------------------------------
83
84
    /**
85
     * AbstractSingleton::__wakeup
86
     *
87
     * Application of __wakeup magic method with private visibiliry to prevent unserializing of
88
     * the *Singleton* instance.
89
     *
90
     * @return void
91
     */
92
    protected function __wakeup()
93
    {
94
    }
95
}