WP_AI_Client_Prompt_Builder::get_builder_callable( string $name ): callable

In this article

Retrieves a callable for a given PHP AI Client SDK prompt builder method name.

Parameters

$namestringrequired
The method name in snake_case.

Return

callable The callable for the specified method.

Source

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;
}

Changelog

VersionDescription
7.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.