ClassUtils::getRealClass()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 4
nop 1
1
<?php
2
namespace Workana\AsyncJobs\Util;
3
4
5
use Doctrine\ORM\Proxy\Proxy;
6
7
class ClassUtils
8
{
9
    /**
10
     * Get real class
11
     *
12
     * @param object|string $target
13
     *
14
     * @return string
15
     */
16
    public static function getRealClass($target)
17
    {
18
        if (!is_object($target)) {
19
            return '';
20
        }
21
22
        if (is_a($target, Proxy::class, true)) {
23
            return get_parent_class($target);
24
        } else {
25
            return is_string($target) ? $target : get_class($target);
26
        }
27
    }
28
}