WP_AI_Client_Prompt_Builder::get_builder_callable
Retrieves a callable for a given PHP AI Client SDK prompt builder method name.
Method of the class: WP_AI_Client_Prompt_Builder{}
No Hooks.
Returns
callable. The callable for the specified method.
Usage
// protected - for code of main (parent) or child class $result = $this->get_builder_callable( $name ): callable;
- $name(string) (required)
- The method name in snake_case.
Changelog
| Since 7.0.0 | Introduced. |
WP_AI_Client_Prompt_Builder::get_builder_callable() WP AI Client Prompt Builder::get builder callable code WP 7.0
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;
}