MailPoet\EmailEditor\Validator

Validator::get_type_error()privateWC 1.0

Returns a WP_Error for a type mismatch.

Method of the class: Validator{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->get_type_error( $param, $type ): WP_Error;
$param(string) (required)
The parameter name.
$type(string|string[]) (required)
The expected type.

Validator::get_type_error() code WC 9.8.1

private function get_type_error( string $param, $type ): WP_Error {
	$type = is_array( $type ) ? $type : array( $type );
	return new WP_Error(
		'rest_invalid_type',
		// translators: %1$s is the current parameter and %2$s a comma-separated list of the allowed types.
		sprintf( __( '%1$s is not of type %2$s.', 'woocommerce' ), $param, implode( ',', $type ) ),
		array( 'param' => $param )
	);
}