Passed
Branch staging (dcaea3)
by Tony Karavasilev (Тони
02:31
created

AbstractSingleton::getInstance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Abstraction for the singleton design pattern.
5
 */
6
7
namespace CryptoManana\Core\Abstractions\DesignPatterns;
8
9
use CryptoManana\Core\Interfaces\DesignPatterns\SingleInstancingInterface as SingleInstancing;
10
11
/**
12
 * Class AbstractSingleton - Abstraction for the singleton design pattern.
13
 *
14
 * @package CryptoManana\Core\Abstractions\DesignPatterns
15
 */
16
abstract class AbstractSingleton implements SingleInstancing
17
{
18
    /**
19
     * Locks the creation of new objects but allows static creation and extending.
20
     */
21 12
    protected function __construct()
22
    {
23
        /* This may remain empty. */
24 12
        return null;
25
    }
26
27
    /**
28
     * Lock the reinitialization and unserialization abilities of the class.
29
     */
30 12
    public function __wakeup()
31
    {
32
        /* This must remain empty. */
33 12
        return null;
34
    }
35
36
    /**
37
     * Lock the serialization abilities of the class.
38
     */
39 12
    public function __sleep()
40
    {
41
        /* This must remain empty. */
42 12
        return null;
43
    }
44
45
    /**
46
     * Lock the ability to clone properties and create a new dynamic instance of the class.
47
     */
48 12
    private function __clone()
49
    {
50
        /* This must remain empty. */
51 12
        return null;
52
    }
53
54
    /**
55
     * Return the name of the current defined class that extends the class.
56
     *
57
     * @return string Name of the class.
58
     */
59 12
    public function __toString()
60
    {
61 12
        return get_class($this);
62
    }
63
}
64