*/ public static function getErrorCodeNames(): array { return [ 'PARSE_ERROR' => self::PARSE_ERROR, 'INVALID_REQUEST' => self::INVALID_REQUEST, 'METHOD_NOT_FOUND' => self::METHOD_NOT_FOUND, 'INVALID_PARAMS' => self::INVALID_PARAMS, 'INTERNAL_ERROR' => self::INTERNAL_ERROR, 'URL_ELICITATION_REQUIRED' => self::URL_ELICITATION_REQUIRED, ]; } /** * Checks if the given error code is valid. * * @param int $code * @return bool */ public static function isValidErrorCode(int $code): bool { return in_array($code, self::getErrorCodes(), true); } /** * Gets the constant name for an error code. * * @param int $code * @return string|null The constant name, or null if not found */ public static function getErrorCodeName(int $code): ?string { $flipped = array_flip(self::getErrorCodeNames()); return $flipped[$code] ?? null; } /** * Checks if an error code is a standard JSON-RPC error. * * Standard JSON-RPC errors are in the range -32700 to -32600. * * @param int $code * @return bool */ public static function isStandardJsonRpcError(int $code): bool { return $code >= -32700 && $code <= -32600; } }