Completed
Pull Request — master (#1875)
by Andreas
61:52
created

ClassNameResolver::getClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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
    public function __construct(Configuration $configuration)
17
    {
18
        $this->configuration = $configuration;
19
    }
20
21
    /**
22
     * Gets the real class name of a class name that could be a proxy.
23
     */
24
    public function getRealClass(string $class) : string
25
    {
26
        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
    private function getClassNameInflector() : ClassNameInflectorInterface
38
    {
39
        return $this->configuration->getProxyManagerConfiguration()->getClassNameInflector();
40
    }
41
}
42