WP_CLI::read_value()public staticWP-CLI 1.0

Read a value, from various formats.

Method of the class: WP_CLI{}

No Hooks.

Return

null. Nothing.

Usage

$result = WP_CLI::read_value( $raw_value, $assoc_args );
$raw_value(mixed) (required)
-
$assoc_args(array)
-
Default: []

WP_CLI::read_value() code WP-CLI 2.7.0-alpha

public static function read_value( $raw_value, $assoc_args = [] ) {
	if ( Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) {
		$value = json_decode( $raw_value, true );
		if ( null === $value ) {
			self::error( sprintf( 'Invalid JSON: %s', $raw_value ) );
		}
	} else {
		$value = $raw_value;
	}

	return $value;
}