Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4.0218 |
Changes | 0 |
1 | <?php |
||
20 | 5 | public static function detect($class) |
|
21 | { |
||
22 | 5 | $reflection = new \ReflectionClass($class); |
|
23 | |||
24 | 5 | if (PHP_VERSION_ID >= 70100) { |
|
25 | // Since PHP-7.1 visibility modifiers are allowed for class constants |
||
26 | // for enumerations we are only interested in public once. |
||
27 | 5 | $constants = []; |
|
28 | 5 | foreach ($reflection->getReflectionConstants() as $constant) { |
|
29 | 5 | if ($constant->isPublic()) { |
|
30 | 5 | $constants[$constant->getName()] = $constant->getValue(); |
|
31 | } |
||
32 | } |
||
33 | |||
34 | 5 | return $constants; |
|
35 | } |
||
36 | |||
37 | // In PHP < 7.1 all class constants were public by definition |
||
38 | return $reflection->getConstants(); |
||
39 | } |
||
40 | } |
||
41 |