Completed
Push — master ( 4b5952...b8f7dd )
by Andreas
11s
created

ClassNameResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 31
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getRealClass() 0 4 1
A getClass() 0 4 1
A getClassNameInflector() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ODM\MongoDB\Proxy;
6
7
use Doctrine\ODM\MongoDB\Configuration;
8
use ProxyManager\Inflector\ClassNameInflectorInterface;
9
use function get_class;
10
11
final class ClassNameResolver
12
{
13
    /** @var Configuration */
14
    private $configuration;
15
16 1697
    public function __construct(Configuration $configuration)
17
    {
18 1697
        $this->configuration = $configuration;
19 1697
    }
20
21
    /**
22
     * Gets the real class name of a class name that could be a proxy.
23
     */
24 1433
    public function getRealClass(string $class) : string
25
    {
26 1433
        return $this->getClassNameInflector()->getUserClassName($class);
27
    }
28
29
    /**
30
     * Gets the real class name of an object (even if its a proxy).
31
     */
32
    public function getClass(object $object) : string
33
    {
34
        return $this->getRealClass(get_class($object));
35
    }
36
37 1433
    private function getClassNameInflector() : ClassNameInflectorInterface
38
    {
39 1433
        return $this->configuration->getProxyManagerConfiguration()->getClassNameInflector();
40
    }
41
}
42