Renders the string conversion of the value.

@param mixed $value
187880
private function writeValue($value): string
    {
        if ('%%%%not_defined%%%%' === $value) {
            return '';
        }

        if (\is_string($value) || is_numeric($value)) {
            return $value;
        }

        if (false === $value) {
            return 'false';
        }

        if (true === $value) {
            return 'true';
        }

        if (null === $value) {
            return 'null';
        }

        if (empty($value)) {
            return '';
        }

        if (\is_array($value)) {
            return implode(',', $value);
        }
    }
1219293
protected function prepareHeaderValue($value)
    {
        if (is_string($value)) {
            $value = [$value];
        }
        if (! is_array($value)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid header value "%s"; must be a string or array of strings.',
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }
        foreach ($value as &$item) {
            if (! is_string($item)) {
                throw new InvalidArgumentException(sprintf(
                    'Invalid header value "%s"; must be a string.',
                    is_object($item) ? get_class($item) : gettype($item)
                ));
            }

            $item = trim($item);

            if ('' === $item) {
                throw new InvalidArgumentException(
                    'Empty header value provided.'
                );
            }

            if (preg_match('/[^\x09\x0a\x0d\x20-\x7E\x80-\xFE]/', $item)) {
                throw new InvalidArgumentException(sprintf(
                    'The header value "%s" contains illegal characters.',
                    $item
                ));
            }
            $item = preg_replace('/\s+/', ' ', $item);
        }

        return $value;
    }
1123505
public static function format($value)
    {
        $value = Utils::toString($value);
        $bn = Utils::toBn($value);
        $int = (int) $bn->toString();

        return $int;
    }
779225
private function resolveComponent(&$value)
    {
        if (\is_string($value) && strpos($value, '@') === 0) {
            $value = $this->getComponent(substr($value, 1));
        }
    }
473963
protected function explodeDateString($value)
    {
        // split on known delimiters (. / -)
        if (!preg_match(
            '#^(?<first>\\d+)[-/\\.](?<second>\\d+)[-/\\.](?<third>\\d+)(?<time>.*)$#',
            $value,
            $matches
        )) {
            throw new InvalidArgumentException(
                "Invalid date: '$value'. Use " . self::ISO_DATE . " to prevent this error."
            );
        }

        $parts = [
            $matches['first'],
            $matches['second'],
            $matches['third']
        ];
        // Flip d-m-y to y-m-d
        if ($parts[0] < 1000 && $parts[2] > 1000) {
            $parts = array_reverse($parts);
        }
        if ($parts[0] < 1000 && (int)$parts[0] !== 0) {
            throw new InvalidArgumentException(
                "Invalid date: '$value'. Use " . self::ISO_DATE . " to prevent this error."
            );
        }
        $parts[] = $matches['time'];
        return $parts;
    }
1322590
public function renderJson($value)
    {
        $options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP;
        return json_encode($value, $options);
    }
1323206
public function displayValue( $value )
    {
        if ( isset( $this->values[$value] ) )
        {
            $value = $this->values[$value];
        }

        if ( $this->translationEnabled )
        {
            $value = parent::displayValue( $value );
        }

        return $value;
    }
1118752
public function format($value)
    {
        if (!$this->validate($value))
            throw new \InvalidArgumentException("`{$value}` is not a valid HTTP URI");

        $url = Http::createFromString($value);

        if ($url->getScheme() == '') {
            $url = $url->withScheme('http');
        }

        return (String)$url;
    }
22209
protected function prepareValue($value)
    {
        switch (gettype($value)) {
            case OptionInterface::TYPE_BOOLEAN:
                return ($value) ? 'true' : 'false';
            case OptionInterface::TYPE_NUMBER:
                return $value;
            case OptionInterface::TYPE_STRING:
                return "'" . $value . "'";
        }
    }
729490
private static function normalizeValue($value)
    {
        if (is_string($value)) {
            $value = str_ireplace(['&nbsp;', '&#160;'], ' ', $value);
            $value = trim($value);

            return ($value === '') ? null : $value;
        }

        return $value;
    }
35373
public function itemValuetoStringRepresentation($value)
    {
        if (is_bool($value))
        {
            $castedValue = (true === $value) ? 'true' : 'false';
        }
        elseif (is_null($value))
        {
            $castedValue = 'null';
        }
        elseif (is_array($value))
        {
            $castedValue = [];
            foreach ($value as $k => $v)
            {
                $castedValue[$k] = $this->itemValuetoStringRepresentation($v);
            }
        }
        elseif (is_numeric($value))
        {
            $castedValue = (string)$value;
        }
        elseif (is_string($value))
        {
            $castedValue = $value;
        }
        else
        {
            throw new InvalidDataException('Invalid item value type!');
        }

        return $castedValue;
    }
1158745
public static function prep_value($value) {
		if (\is_array($value)) {
			$value=implode(",", $value);
		}
		if (self::containsCode($value)===false) {
			$value=\str_replace(["\\","\""], ["\\\\","\\\""], $value);
			$value='"'.$value.'"';
		}
		return trim($value,"%");
	}
707978
public function compileString($value)
    {
        if (is_null(static::$cssFilesContent)) {
            static::$cssFilesContent = $this->getCssFilesContent($this->cssFiles);
        }

        return parent::compileString($this->convertStyles($value));
    }
1222663
public function compile($value = "")
	{
		$html = $this->compiledLabel;

		if (!empty($this->help)) {
			$html .= "<div class='help'>{$this->help}</div>";
		}

		$html .= "<input type=\"{$this->type}\" name=\"{$this->name}\" {$this->compiledAttr} value=\"{$value}\" />";

		return $html;
	}
822059
protected function valueToString($value) : string
    {
        if ($value === null) {
            $def_value = 'null';
        } elseif ($value === false) {
            $def_value = 'false';
        } elseif ($value === true) {
            $def_value = 'true';
        } elseif (is_string($value)) {
            $def_value = '"' . str_replace('"', '\\"', $value) . '"';
        } elseif (is_numeric($value)) {
            $def_value = '' . $value;
        }

        return $def_value;
    }
283766
private function stringifyValue($value)
    {
        switch (true) {
            case $value === null:
                $value = 'NULL';
                break;
            case ($value instanceof \DateTime):
                $value = $value->format(DATE_RFC822);
                break;
            case ($value instanceof StringableInterface):
                $value = $value->toString();
                break;
            case ($value instanceof ArrayableInterface):
                $value = sprintf('Arrayable::%s (%s)', (new \ReflectionObject($value))->getShortName(),
                    $this->stringifyValue($value->toArray()));
                break;
            case is_scalar($value):
            case method_exists($value, '__toString'):
                $value = (string) $value;
                break;
            case is_object($value):
                $value = sprintf('Object (%s)', get_class($value));
                break;
            case is_array($value):
                $value = sprintf('Array (%s)', implode(', ', array_map([$this, 'stringifyValue'], $value)));
                break;
        }
        
        return $value;
    }
322106
public function unserialize($value)
    {
        if ($value === null || is_scalar($value)) {
            $this->str = unserialize($value);
        } else {
            throw new \InvalidArgumentException(sprintf('HString cannot unserialize a %s', Helper::getType($value)));
        }
    }