ReflectionSingleton::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Pgs\ElasticOM;
4
5
class ReflectionSingleton
6
{
7
    private static $instances = [];
8
9 2
    public static function getInstance(string $name): \ReflectionClass
10
    {
11 2
        if (!isset(self::$instances[$name])) {
12 2
            self::$instances[$name] = new \ReflectionClass($name);
13
        }
14
15 2
        return self::$instances[$name];
16
    }
17
}
18