ObjectUtils   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConstants() 0 11 3
1
<?php
2
namespace Bedd\Common;
3
4
use Bedd\Common\Traits\StaticClassTrait;
5
6
/**
7
 * ObjectUtils
8
 */
9
class ObjectUtils
10
{
11
    use StaticClassTrait;
12
13
    /**
14
     * Get all constants of the given $class or object.
15
     * Constant name in key, constant value in value.
16
     *
17
     * @param object|string $class
18
     * @return array
19
     */
20
    public static function getConstants($class)
21
    {
22
        static $constants = [];
23
        if (is_object($class)) {
24
            $class = get_class($class);
25
        }
26
        if (!isset($constants[$class])) {
27
            $constants[$class] = (new \ReflectionClass($class))->getConstants();
28
        }
29
        return $constants[$class];
30
    }
31
}
32