Passed
Pull Request — master (#48)
by Damien
02:20
created

DoctrineHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getRealClass() 0 9 3
1
<?php
2
3
namespace DH\DoctrineAuditBundle;
4
5
use Doctrine\ORM\Proxy\Proxy;
6
7
class DoctrineHelper
8
{
9
    /**
10
     * Gets the real class name of a class name that could be a proxy.
11
     *
12
     * @param object|string $subject
13
     *
14
     * @return string
15
     */
16
    public static function getRealClass($subject): string
17
    {
18
        $class = \is_object($subject) ? \get_class($subject) : $subject;
19
20
        if (false === $pos = strrpos($class, '\\'.Proxy::MARKER.'\\')) {
21
            return $class;
22
        }
23
24
        return substr($class, $pos + Proxy::MARKER_LENGTH + 2);
25
    }
26
}
27