It looks like nothing was found at this location. Maybe try one of the links below or a search?
PI responses * or other contexts where HTTP semantics are relevant. * * @since 7.0.0 * * @param Exception $e The exception to convert. * @return WP_Error The resulting WP_Error object. */ private function exception_to_wp_error( Exception $e ): WP_Error { if ( $e instanceof NetworkException ) { $error_code = 'prompt_network_error'; $status_code = 503; } elseif ( $e instanceof ClientException ) { // `ClientException` uses HTTP status codes as exception codes, so we can rely on them. $error_code = 'prompt_client_error'; $status_code = $e->getCode() ? $e->getCode() : 400; } elseif ( $e instanceof ServerException ) { // `ServerException` uses HTTP status codes as exception codes, so we can rely on them. $error_code = 'prompt_upstream_server_error'; $status_code = $e->getCode() ? $e->getCode() : 500; } elseif ( $e instanceof TokenLimitReachedException ) { $error_code = 'prompt_token_limit_reached'; $status_code = 400; } elseif ( $e instanceof InvalidArgumentException ) { $error_code = 'prompt_invalid_argument'; $status_code = 400; } else { $error_code = 'prompt_builder_error'; $status_code = 500; } return new WP_Error( $error_code, $e->getMessage(), array( 'status' => $status_code, 'exception_class' => get_class( $e ), ) ); } /** * Checks if a method name is a support check method (is_supported*). * * @since 7.0.0 * * @param string $name The method name. * @return bool True if the method is a support check method, false otherwise. */ private static function is_support_check_method( string $name ): bool { return isset( self::$support_check_methods[ $name ] ); } /** * Checks if a method name is a generating method (generate_*, convert_text_to_speech*). * * @since 7.0.0 * * @param string $name The method name. * @return bool True if the method is a generating method, false otherwise. */ private static function is_generating_method( string $name ): bool { return isset( self::$generating_methods[ $name ] ); } /** * Retrieves a callable for a given PHP AI Client SDK prompt builder method name. * * @since 7.0.0 * * @param string $name The method name in snake_case. * @return callable The callable for the specified method. * * @throws BadMethodCallException If the method does not exist. */ protected function get_builder_callable( string $name ): callable { $camel_case_name = $this->snake_to_camel_case( $name ); $method = array( $this->builder, $camel_case_name ); if ( ! is_callable( $method ) ) { throw new BadMethodCallException( sprintf( /* translators: 1: Method name. 2: Class name. */ __( 'Method %1$s does not exist on %2$s.' ), $name, // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped get_class( $this->builder ) // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped ) ); } return $method; } /** * Converts snake_case to camelCase. * * @since 7.0.0 * * @param string $snake_case The snake_case string. * @return string The camelCase string. */ private function snake_to_camel_case( string $snake_case ): string { $parts = explode( '_', $snake_case ); $camel_case = $parts[0]; $parts_count = count( $parts ); for ( $i = 1; $i < $parts_count; $i++ ) { $camel_case .= ucfirst( $parts[ $i ] ); } return $camel_case; } }
It looks like nothing was found at this location. Maybe try one of the links below or a search?