18 if (self::$constCacheArray == NULL) {
19 self::$constCacheArray = [];
21 $calledClass = get_called_class();
22 if (! \array_key_exists($calledClass, self::$constCacheArray)) {
23 $reflect = new \ReflectionClass($calledClass);
24 self::$constCacheArray[$calledClass] = $reflect->getConstants();
26 return self::$constCacheArray[$calledClass];
31 return \array_values(self::getConstants());
33 if ($prefixBefore ===
false) {
34 return \array_map(
function ($elem) use ($postFix) {
35 return $elem .
" " . $postFix;
36 }, \array_values(self::getConstants()));
38 return \array_map(
function ($elem) use ($postFix) {
39 return $postFix .
" " . $elem;
40 }, \array_values(self::getConstants()));
46 $constants = self::getConstants();
49 return \array_key_exists($name, $constants);
52 $keys = \array_map(
'strtolower', array_keys($constants));
53 return \in_array(\strtolower($name), $keys);
57 $values = \array_values(self::getConstants());
58 return \in_array($value, $values,
true);
62 $values = self::getConstantValues();
64 $calledClass = \get_called_class();
65 if ($unique && $count >
count(self::$picked[$calledClass] ?? [])) {
67 $newVal = $values[\rand(0, $count - 1)];
68 }
while (isset(self::$picked[$calledClass][$newVal]));
69 self::$picked[$calledClass][$newVal] =
true;
72 return $values[\rand(0, $count - 1)];
static getRandomValue(bool $unique=false)
static isValidName($name, $strict=false)
static getConstantValues($postFix="", $prefixBefore=false)
Base class for enums see at http://stackoverflow.com/questions/254514/php-and-enumerations.
static isValidValue($value)