Passed
Branch staging (6d4670)
by Tony Karavasilev (Тони
04:18
created

AbstractSingleton   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 6
c 0
b 0
f 0
dl 0
loc 46
ccs 10
cts 10
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 3 1
A __sleep() 0 4 1
A __clone() 0 4 1
A __wakeup() 0 4 1
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 6
    protected function __construct()
22
    {
23
        /* This may remain empty. */
24 6
        return null;
25
    }
26
27
    /**
28
     * Lock the reinitialization and unserialization abilities of the class.
29
     */
30 6
    public function __wakeup()
31
    {
32
        /* This must remain empty. */
33 6
        return null;
34
    }
35
36
    /**
37
     * Lock the serialization abilities of the class.
38
     */
39 6
    public function __sleep()
40
    {
41
        /* This must remain empty. */
42 6
        return null;
43
    }
44
45
    /**
46
     * Lock the ability to clone properties and create a new dynamic instance of the class.
47
     */
48 6
    private function __clone()
49
    {
50
        /* This must remain empty. */
51 6
        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 6
    public function __toString()
60
    {
61 6
        return get_class($this);
62
    }
63
}
64