ReflectionPool::getInstance()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 4 Features 0
Metric Value
c 5
b 4
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 7
nc 4
nop 1
1
<?php
2
3
namespace PEIP\Util;
4
5
/*
6
 * To change this template, choose Tools | Templates
7
 * and open the template in the editor.
8
 */
9
10
/**
11
 * Description of ReflectionPool.
12
 *
13
 * @author timo
14
 */
15
class ReflectionPool
16
{
17
    protected static $instances = [];
18
19
    /**
20
     * Constructs a ReflectionClass.
21
     *
22
     * @param $argument
23
     *
24
     * @return ReflectionClass
25
     */
26
    public static function getInstance($argument)
27
    {
28
        $className = is_object($argument)
29
            ? get_class($argument)
30
            : (string) $argument;
31
32
        return isset(self::$instances[$className])
33
            ? self::$instances[$className]
34
            : self::$instances[$className] = new \ReflectionClass($className);
35
    }
36
}
37