Parsea un valor

@param string $key
@param mixed  $value

@return string
553953
private function parseValue(string $key, $value): string
    {

        if (is_array($value)) {
            return $this->parseArray($key, $value);
        }

        return $this->parseScalar($key, $value);
    }
137114
public static function parse($value) {
        if ($value instanceof Color) {
            return $value;
        }
        
        $value = strtolower("$value");
        
        if (preg_match('/^#?[0-9a-f]{3,8}$/', $value) &&
            self::parseHexColor($value, $result)
        ) {
            return $result;
        }
        
        if (preg_match(
                '/^rgba?\\(([^,]+),([^,]+),([^,]+)(?:,([^,]+))?\\)$/', 
                $value, $matches) &&
            self::parseRgbComponent($matches[1], $r) &&
            self::parseRgbComponent($matches[2], $g) &&
            self::parseRgbComponent($matches[3], $b) &&
            self::parseAlpha(isset($matches[4]) ? $matches[4] : null, $a)
        ) {
            return self::fromRgb($r, $g, $b, (int)(255 * $a));
        }
        
        if (preg_match(
                '/^hsla?\\(([^,]+),([^,]+),([^,]+)(?:,([^,]+))?\\)$/', 
                $value, $matches) &&
            self::parseHue($matches[1], $h) &&
            self::parsePercent($matches[2], $s) &&
            self::parsePercent($matches[3], $l) &&
            self::parseAlpha(isset($matches[4]) ? $matches[4] : null, $a)
        ) {
            return self::fromHsl($h, $s, $l, $a);
        }
        
        $result = self::parseNamedColor($value);
        if ($result !== null) {
            return $result;
        }
        
        throw new \InvalidArgumentException(
            "Cannot parse '$value' as a color.");
    }
1178751
public function set($key, $value) {
        setvalr(trim($key), $this->data, $value);
        return $value;
    }
618983
public function withValue($key, $value)
    {
        $copy = $this->values;
        $copy[$key] = $value;
        return new Context($copy);
    }
1113228
public static function parseData($value)
	{
		$ciphertext = base64_decode($value);

		// Get the IV
		$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
		$iv     = substr($ciphertext, 0, $ivSize);

		// Get just the cipher without the IV
		$ciphertext = substr($ciphertext, $ivSize);

		// Generate key and decrypt
		$key       = md5(\App::get('config')->get('secret'));
		$plaintext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $ciphertext, MCRYPT_MODE_CBC, $iv);

		return $plaintext;
	}
729396
private function getParsedValue($value)
    {
        try {
            $requestValue = $this->decodeJson($value);
        } catch (\InvalidArgumentException $e) {
            $requestValue = $value;
            $this->logger->warning('Invalid json received in request: ' . $value);
        }

        return $requestValue;
    }
872248
private static function parseReal($value)
    {
        if ($value == '') return null;

        $x = str_replace(',', '.', $value);
        if (static::isSignedReal($x)) return floatval($x);
        else throw new SyntaxErrorException();
    }
942828
private function getValue($value)
    {
        if (!is_string($value)) {
            return $value;
        }

        if ($value[0] != '%' || $value[strlen($value) - 1] != '%')  {
            return $value;
        }

        $parameter = trim($value, '%');
        if ($this->container->hasParameter($parameter)) {
            return $this->container->getParameter($parameter);
        }

        return $value;
    }
548714
public function parse_value($value) {
        global $COURSE;

        if (strpos($value, '$LineItems.url') !== false) {
            $this->params['context_id'] = $COURSE->id;
            $value = str_replace('$LineItems.url', parent::get_endpoint(), $value);
        }

        return $value;

    }
1319475
protected function getValue( $key, $value = null )
	{
		if( is_null( $value ) && isset( $this->args[$key] )) {
			$value = $this->args[$key];
		}
		return $value;
	}
846813
function parseValue($value) {
        try {
            return \Plasma\Types\TypeExtensionsManager::getManager()->decodeType($this->type, $value)->getValue();
        } catch (\Plasma\Exception $e) {
            /* Continue regardless of error */
        }
        
        return $value;
    }
356500
protected function preparePartValue(string $key, $value)
    {
        if (! isset($this->partClassMap[$key])) {
            return $value;
        }

        $className = $this->partClassMap[$key];

        return ! $value instanceof $className ? new $className($value) : $value;
    }
554798
static public function parseValue($value) {
		$value = trim($value);
		
		if (is_numeric($value)) {
			$valueOrigin = $value;

			if (strpos($value, '.') === false) {
				$value = (int) $value;
			} else {
				$value = (float) $value;
			}

			// Overflow checking
			if ($valueOrigin !== (string) $value) {
				$value = $valueOrigin;
			}
		}
		
		return $value;
	}
536661
public function parse_value($value) {

        if (empty($this->resources)) {
            $this->resources = $this->get_resources();
        }
        if (!empty($this->resources)) {
            foreach ($this->resources as $resource) {
                $value = $resource->parse_value($value);
            }
        }

        return $value;

    }
1073776
protected function parsePropertyValue($value)
    {
        $return = '';

        if (is_array($value)) {
            $withStringIndex = (bool) array_filter(array_keys($value), 'is_string');

            if ($withStringIndex) {
                $return = preg_replace(
                    ['/^(array ?\( *)/', '/\)$/'],
                    ['[', ']'],
                    str_replace("\n", '', var_export($value, true))
                );
            } else {
                $return =
                    '[' .
                    rtrim(
                        array_reduce(
                            $value,
                            function ($combined, $single) {
                                return $combined . var_export($single, true) . ', ';
                            },
                            ''
                        ),
                        ', '
                    ) .
                    ']';
            } // else
        } else {
            $return = var_export($value, true);
        } // else

        return $return;
    }
736235
protected function getContent($key, $value)
    {
        $headerPath = $this->getHeaderPath($key);
        $header = !is_null($headerPath) && file_exists($headerPath)
            ? file_get_contents($headerPath)
            : $this->getDefaultHeader($key);
            
        return $header.PHP_EOL."return ".common_Utils::toHumanReadablePhpString($value).";".PHP_EOL;
    }
487362
private function item($key, string $value): string
    {
        // 整型,表示不用关注 数组的键了.
        if (is_int($key)) {
            list($key, $value) = $this->itemWithoutKey($value);
        }

        // 去多余的空格
        $key = trim($key);
        $value = trim($value);

        // 如果 字段和方向的顺序写反了,翻过来
        if (strtoupper($key) == 'ASC' or strtoupper($key) == 'DESC') {
            list($key, $value) = [$value, $key];
        }

        // 已经确定了字段和方向
        $field = $key;
        $dim = strtoupper($value);

        // 排序中的方向不被允许
        if ($dim != 'ASC' and $dim != 'DESC') {
            trigger_error('排序方向只能使用ASC或DESC:'.$dim,E_USER_ERROR);
        }

        // 构造SQL中排序语法: 空格分隔
        if ($this->isField($field)) {
            $field = $this->markField($field);
        }

        return $field . ' ' . $dim;
    }