Constants   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 8
c 1
b 0
f 1
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConstantsValues() 0 9 3
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Utils;
5
6
use Nette\Utils\Strings;
7
8
/**
9
 * Constants
10
 *
11
 * @author Jakub Konečný
12
 */
13 1
final class Constants {
14
  use \Nette\StaticClass;
15
  
16
  /**
17
   * Get values of all constants from class $class whose name starts with $prefix
18
   *
19
   * @throws \ReflectionException
20
   */
21
  public static function getConstantsValues(string $class, string $prefix = ""): array {
22 1
    $values = [];
23 1
    $constants = (new \ReflectionClass($class))->getConstants();
24 1
    foreach($constants as $name => $value) {
25 1
      if(Strings::startsWith($name, $prefix)) {
26 1
        $values[] = $value;
27
      }
28
    }
29 1
    return $values;
30
  }
31
}
32
?>