value array. */ public static function all(): array { $options = []; foreach ((new \ReflectionClass(static::class))->getConstants() as $name => $value) { $options[strtolower($name)] = $value; } return $options; } public static function levelNameToValue(string $level): int { return static::all()[$level] ?? -1; } public static function levelValueToName(int $level): string { foreach (static::all() as $name => $value) { if ($level === $value) { return $name; } } return 'default'; } }