[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ai-client/ -> class-wp-ai-client-builder.php (summary)

WP AI Client: WP_AI_Client_Builder class

File Size: 408 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 8 functions

  __construct()
  __clone()
  __call()
  throwable_to_wp_error()
  is_support_check_method()
  is_generating_method()
  get_builder_callable()
  snake_to_camel_case()

Functions
Functions that are not part of a class:

__construct( ProviderRegistry $registry, $input = null )   X-Ref
Constructor.

param: ProviderRegistry $registry The provider registry for finding suitable models.
param: mixed            $input    Optional. Initial input content for the builder.

__clone()   X-Ref
Clones the wrapped builder alongside this instance.

The wrapped builder mutates its own state, so without this a clone would
share that state with the original and any change made to one would be
visible in the other.


__call( string $name, array $arguments )   X-Ref
Magic method to proxy snake_case method calls to their PHP AI Client camelCase counterparts.

This allows WordPress developers to use snake_case naming conventions. It catches
any exceptions thrown, stores them, and returns a WP_Error when a terminate method
is called, or false when a support check method is called.

return: mixed The result of the method call.
param: string            $name      The method name in snake_case.
param: array<int, mixed> $arguments The method arguments.

throwable_to_wp_error( Throwable $throwable )   X-Ref
Converts a throwable into a WP_Error with a structured error code and message.

This method maps different throwable types to specific WP_Error codes and HTTP status codes.
The presence of the status codes means these WP_Error objects can be easily used in REST API responses
or other contexts where HTTP semantics are relevant.

return: WP_Error The resulting WP_Error object.
param: Throwable $throwable The throwable to convert.

is_support_check_method( string $name )   X-Ref
Checks if a method name is a support check method (is_supported*).

return: bool True if the method is a support check method, false otherwise.
param: string $name The method name.

is_generating_method( string $name )   X-Ref
Checks if a method name is a generating method (generate_*, convert_text_to_speech*).

return: bool True if the method is a generating method, false otherwise.
param: string $name The method name.

get_builder_callable( string $name )   X-Ref
Retrieves a callable for a given PHP AI Client SDK builder method name.

return: callable The callable for the specified method.
param: string $name The method name in snake_case.

snake_to_camel_case( string $snake_case )   X-Ref
Converts snake_case to camelCase.

return: string The camelCase string.
param: string $snake_case The snake_case string.



Generated : Wed Oct 14 08:20:33 2026 Cross-referenced by PHPXref