Multiton::__sleep()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 0
c 2
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author  : Jagepard <[email protected]>
7
 * @license https://mit-license.org/ MIT
8
 */
9
10
namespace AntiPatterns\Multiton;
11
12
class Multiton
13
{
14
    protected static array $instances = [];
15
16
    /**
17
     * Gets an object instance
18
     * --------------------------
19
     * Получает экземпляр объекта
20
     *
21
     * @return self
22
     */
23
    public static function getInstance(): self
24
    {
25
        $that = get_called_class();
26
27
        if (!array_key_exists($that, static::$instances)){
28
            static::$instances[$that] = new static();
29
        }
30
31
        return static::$instances[$that];
32
    }
33
34
    public function __construct()
35
    {
36
    }
37
38
    /**
39
     * @codeCoverageIgnore
40
     */
41
    public function __sleep()
42
    {
43
    }
44
45
    /**
46
     * @codeCoverageIgnore
47
     */
48
    public function __wakeup()
49
    {
50
    }
51
52
    /**
53
     * @codeCoverageIgnore
54
     */
55
    public function __clone()
56
    {
57
    }
58
}
59