Failed Conditions
Pull Request — develop (#6719)
by Marco
61:19
created

StaticClassNameConverter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
4
declare(strict_types=1);
5
6
namespace Doctrine\ORM\Utility;
7
8
use ProxyManager\Configuration;
9
use ProxyManager\Inflector\ClassNameInflectorInterface;
10
11
/**
12
 * This class provides utility method to retrieve class names, and to convert
13
 * proxy class names to original class names
14
 *
15
 * @since  3.0
16
 * @author Jasper N. Brouwer <[email protected]>
17
 */
18
abstract class StaticClassNameConverter
19
{
20
    /**
21
     * @var ClassNameInflectorInterface|null
22
     */
23
    private static $classNameInflector;
24
25
    final private function __construct()
26
    {
27
    }
28
29
    /**
30
     * Gets the real class name of a class name that could be a proxy.
31
     *
32
     * @param string $class
33
     *
34
     * @return string
35
     */
36
    public static function getRealClass($class)
37
    {
38
        $inflector = self::$classNameInflector
39
            ?? self::$classNameInflector = (new Configuration())->getClassNameInflector();
40
41
        return $inflector->getUserClassName($class);
42
    }
43
44
    /**
45
     * Gets the real class name of an object (even if its a proxy).
46
     *
47
     * @param object $object
48
     *
49
     * @return string
50
     */
51
    public static function getClass($object)
52
    {
53
        $inflector = self::$classNameInflector
54
            ?? self::$classNameInflector = (new Configuration())->getClassNameInflector();
55
56
        return $inflector->getUserClassName(\get_class($object));
57
    }
58
}
59