ClassLookup   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 29
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getClass() 0 4 2
A getClassName() 0 7 2
1
<?php
2
3
namespace Kunstmaan\UtilitiesBundle\Helper;
4
5
use Doctrine\ORM\Proxy\Proxy;
6
7
/**
8
 * Helper for looking up the classname, not the ORM proxy
9
 */
10
class ClassLookup
11
{
12
    /**
13
     * Get full class name of object (ie. class name including full namespace)
14
     *
15
     * @param mixed $object
16
     *
17
     * @return string the name of the class and if the given $object isn't a vaid Object false will be returned
18
     */
19 23
    public static function getClass($object)
20
    {
21 23
        return ($object instanceof Proxy) ? get_parent_class($object) : \get_class($object);
22
    }
23
24
    /**
25
     * Get class name of object (ie. class name without namespace)
26
     *
27
     * @param string|object $reference
28
     *
29
     * @return string
30
     */
31 1
    public static function getClassName($reference)
32
    {
33 1
        $reference = \is_string($reference) ? $reference : self::getClass($reference);
34 1
        $className = explode('\\', $reference);
35
36 1
        return array_pop($className);
37
    }
38
}
39