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

ClassNameResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 55.56%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 31
ccs 5
cts 9
cp 0.5556
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getRealClass() 0 4 1
A getClass() 0 4 1
A getClassNameInflector() 0 5 1
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