Issues (2)

src/SingletonsPool.php (1 issue)

Labels
Severity
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\SingletonsPool;
11
12
final class SingletonsPool
13
{
14
    private static array $instances = [];
15
16
    /**
17
     * Gets an object instance
18
     * --------------------------
19
     * Получает экземпляр объекта
20
     *
21
     * @param  string $name
22
     * @return self
23
     */
24
    public static function getInstance(string $name): self
25
    {
26
        if (!array_key_exists($name, static::$instances)) {
0 ignored issues
show
Since $instances is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $instances to at least protected.
Loading history...
27
            static::$instances[$name] = new static;
28
        }
29
30
        return static::$instances[$name];
31
    }
32
33
    public function __construct()
34
    {
35
    }
36
37
    /**
38
     * @codeCoverageIgnore
39
     */
40
    public function __sleep()
41
    {
42
    }
43
44
    /**
45
     * @codeCoverageIgnore
46
     */
47
    public function __wakeup()
48
    {
49
    }
50
51
    /**
52
     * @codeCoverageIgnore
53
     */
54
    public function __clone()
55
    {
56
    }
57
}
58