WP_CLI::read_value()
Read a value, from various formats.
Method of the class: WP_CLI{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = WP_CLI::read_value( $raw_value, $assoc_args );
- $raw_value(mixed) (required)
- -
- $assoc_args(array)
- -
Default: []
WP_CLI::read_value() WP CLI::read value code WP-CLI 2.8.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; }