Read a value, from various formats.

@access public
@category Input

@param mixed $value
@param array $assoc_args
199220
public static function read_value( $raw_value, $assoc_args = array() ) {
		if ( \WP_CLI\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;
	}
1183152
public function get( $args, $assoc_args ) {
		list( $alias ) = $args;

		$aliases = WP_CLI::get_runner()->aliases;

		if ( empty( $aliases[ $alias ] ) ) {
			WP_CLI::error( "No alias found with key '{$alias}'." );
		}

		foreach ( $aliases[ $alias ] as $key => $value ) {
			WP_CLI::log( "{$key}: {$value}" );
		}
	}
1113860
public static function isLessThan($expected, $value, $format, $args = null, $_ = null) {
        if ($expected <= $value) {
            self::vfail($format, array_slice(func_get_args(), 3));
        }
        return $value;
    }
702480
static function text($name, $value, $attr = array())
    {
        $attr = array_merge(
            array(
                "type" => "text"
            ),
            $attr
        );

        self::input($name, $value, $attr);
    }
1229631
public static function isExisting(&$value, $format, $args = null, $_ = null) {
        if (!isset($value)) {
            self::vfail($format, array_slice(func_get_args(), 2));
        }
        return $value;
    }
350575
public function processAttribute($value, ViewableData $object, ViewableData $parent = null, $args = [])
    {
        // Does the value refer to a field or method?
        
        if (strpos($value, '$') === 0) {
            
            // Obtain Field Name:
            
            $field = ltrim($value, '$');
            
            // Detect Object Relationship Format:
            
            if (strpos($field, '.') !== false) {
                
                // Expand Relation Path:
                
                $relations = explode('.', $field);
                
                // Obtain First Relation Name:
                
                $name = array_shift($relations);
                
                // Detect Accessor Method:
                
                if ($object->hasMethod("get{$name}")) {
                    $name = "get{$name}";
                }
                
                // Prepend First Relation Name:
                
                array_unshift($relations, $name);
                
                // Answer Relation Path Value:
                
                return $object->relField(implode('.', $relations));
                
            }
            
            // Obtain Field Value:
            
            if ($object->hasMethod("get{$field}")) {
                
                // First, answer the result of a method call on the receiver:
                
                return call_user_func_array(
                    [$object, "get{$field}"],
                    $this->processAttributeArgs($args, $object, $parent)
                );
                
            } elseif ($object->hasField($field)) {
                
                // Next, answer a field value from the given object:
                
                return $object->$field;
                
            } elseif (is_object($parent) && $parent->hasField($field)) {
                
                // Finally, answer a field value from the given parent object:
                
                return $parent->$field;
                
            }
            
        }
        
        // Answer Value:
        
        return $value;
    }
1307434
function _prepareValue($value, $assoc)
    {
        if (null === $value) {
            return null;
        } elseif (!$assoc) {
            return $value;
        } else {
            $name = $this->getName();
            if (!strpos($name, '[')) {
                return array($name => $value);
            } else {
                $keys = str_replace(
                    array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"),
                    $name
                );
                $keysArray = explode("']['", $keys);
                return HTML_QuickForm_utils::recursiveBuild($keysArray, $value);
            }
        }
    }
624139
protected function jsonDecode(Field $f, $value, $assoc = true)
    {
        // constant supported only starting PHP 7.3
        if (!defined('JSON_THROW_ON_ERROR')) {
            define('JSON_THROW_ON_ERROR', 0);
        }

        $res = json_decode($value, $assoc, 512, JSON_THROW_ON_ERROR);
        if (JSON_THROW_ON_ERROR == 0 && json_last_error() !== JSON_ERROR_NONE) {
            throw new Exception([
                'There was error while decoding JSON',
                'code'  => json_last_error(),
                'error' => json_last_error_msg(),
            ]);
        }

        return $res;
    }
370752
public function info($value, ...$args) {
        return call_user_func_array(
            [__CLASS__, 'event'],
            array_merge([self::INFO, $value], $args)
        );
    }
909052
public function setValue($value)
    {
        if (is_array($value)) {
            if (1 === count($value)) {
                $this->value = $value[0];
            } else {
                throw new \InvalidArgumentException('The argument must either be a string or an array with only one child');
            }
        } else {
            $this->value = $value;
        }
    }
1086661
public function get( $args, $assoc_args ) {
		list( $object_id, $meta_key ) = $args;

		$object_id = $this->check_object_id( $object_id );

		$value = $this->get_metadata( $object_id, $meta_key, true );

		if ( '' === $value ) {
			die( 1 );
		}

		WP_CLI::print_value( $value, $assoc_args );
	}
455443
function offsetSet($offset, $value)
    {
        if (!$value instanceof Attribute) {
            throw new InvalidArgumentException(
                "Value is not an instance of \\Sirel\\Attribute"
            );
        }
        $this->attributes[$offset] = $value;
    }
710519
public function set( $args = array(), $assoc_args = array() ) {
		list( $mod, $value ) = $args;

		set_theme_mod( $mod, $value );

		if ( get_theme_mod( $mod ) === $value ) {
			WP_CLI::success( "Theme mod {$mod} set to {$value}." );
		} else {
			WP_CLI::success( "Could not update theme mod {$mod}." );
		}
	}
132641
public static function addSharedToArgs($arguments = [], $value, $key = null) {
        /** @var SharedDataInterface $instance */
        if (($instance = static::instanceFromArguments($arguments)) === null) {
            return null;
        }
        return $instance->addData($value, $key);
    }
605770
private function process_args( $uri, $assoc_args ) {
		$token                 = isset( $assoc_args['token'] ) ? $assoc_args['token'] : false;
		$bitbucket_private     = isset( $assoc_args['bitbucket-private'] ) ? $assoc_args['bitbucket-private'] : false;
		$cli_config            = [];
		$cli_config['uri']     = $uri;
		$cli_config['private'] = $token ?: $bitbucket_private;
		$cli_config['branch']  = isset( $assoc_args['branch'] ) ? $assoc_args['branch'] : 'master';
		$cli_config['slug']    = isset( $assoc_args['slug'] ) ? $assoc_args['slug'] : null;

		switch ( $assoc_args ) {
			case isset( $assoc_args['github'] ):
				$cli_config['git'] = 'github';
				break;
			case isset( $assoc_args['bitbucket'] ):
				$cli_config['git'] = 'bitbucket';
				break;
			case isset( $assoc_args['gitlab'] ):
				$cli_config['git'] = 'gitlab';
				break;
			case isset( $assoc_args['gitea'] ):
				$cli_config['git'] = 'gitea';
				break;
			case isset( $assoc_args['zipfile'] ):
				$cli_config['git'] = 'zipfile';
				break;
		}

		return $cli_config;
	}
150292
protected function getCallArgs(array $arguments, array $extraArguments, $value = null): array
    {
        foreach ($extraArguments as $name => $val) {
            $arguments[] = $val;
        }

        return $arguments;
    }
401645
public function WriteAssociativeArrayValue($value, $tabAmount = 0) {
        $constantName = strtoupper($value);
        $lineOfCode = str_repeat("  ", $tabAmount) .
                "self::" .
                $constantName . " => '" . $value . "',";
        return $lineOfCode;
    }