Completed
Pull Request — master (#1875)
by Andreas
16:37
created

ClassNameResolver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ODM\MongoDB\Proxy;
6
7
use ProxyManager\Configuration;
8
use ProxyManager\Inflector\ClassNameInflectorInterface;
9
use function get_class;
10
11
final class ClassNameResolver
12
{
13
    /** @var ClassNameInflectorInterface|null */
14
    private static $classNameInflector;
15
16
    private function __construct()
17
    {
18
    }
19
20
    /**
21
     * Gets the real class name of a class name that could be a proxy.
22
     */
23 1433
    public static function getRealClass(string $class) : string
24
    {
25 1433
        return self::getClassNameInflector()->getUserClassName($class);
26
    }
27
28
    /**
29
     * Gets the real class name of an object (even if its a proxy).
30
     */
31
    public static function getClass(object $object) : string
32
    {
33
        return self::getRealClass(get_class($object));
34
    }
35
36 1433
    private static function getClassNameInflector() : ClassNameInflectorInterface
37
    {
38 1433
        return self::$classNameInflector
39 1433
            ?? self::$classNameInflector = (new Configuration())->getClassNameInflector();
40
    }
41
}
42