Singleton::__clone()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace codenixsv\Patterns\Creational\Singleton;
5
6
/**
7
 * Class Singleton
8
 * @package codenixsv\Patterns\Creational\Singleton
9
 */
10
final class Singleton
11
{
12
    /**
13
     * @var Singleton
14
     */
15
    private static $instance;
16
17
    /**
18
     * Singleton constructor.
19
     */
20 1
    private function __construct()
21
    {
22 1
    }
23
24
    /**
25
     * Clone magic method
26
     */
27
    private function __clone()
28
    {
29
    }
30
31
    /**
32
     * Wakeup magic method
33
     */
34
    private function __wakeup()
35
    {
36
    }
37
38
    /**
39
     * @return Singleton
40
     */
41 1
    public static function getInstance(): Singleton
42
    {
43 1
        if (!self::$instance) {
44 1
            self::$instance = new self();
45
        }
46
47 1
        return self::$instance;
48
    }
49
}
50