Failed Conditions
Pull Request — develop (#6719)
by Marco
65:21
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 Marco Pivetta <[email protected]>
17
 *
18
 * @internal do not use in your own codebase: no BC compliance on this class
19
 */
20
abstract class StaticClassNameConverter
21
{
22
    /**
23
     * @var ClassNameInflectorInterface|null
24
     */
25
    private static $classNameInflector;
26
27
    final private function __construct()
28
    {
29
    }
30
31
    /**
32
     * Gets the real class name of a class name that could be a proxy.
33
     *
34
     * @param string $class
35
     *
36
     * @return string
37
     */
38
    public static function getRealClass($class)
39
    {
40
        $inflector = self::$classNameInflector
41
            ?? self::$classNameInflector = (new Configuration())->getClassNameInflector();
42
43
        return $inflector->getUserClassName($class);
44
    }
45
46
    /**
47
     * Gets the real class name of an object (even if its a proxy).
48
     *
49
     * @param object $object
50
     *
51
     * @return string
52
     */
53
    public static function getClass($object)
54
    {
55
        $inflector = self::$classNameInflector
56
            ?? self::$classNameInflector = (new Configuration())->getClassNameInflector();
57
58
        return $inflector->getUserClassName(\get_class($object));
59
    }
60
}
61