Encode a value based on the strategy

@param  string $strategy
@param  string $value

@access public
@return string
428241
public static function encode($strategy, $value)
	{
		switch ($strategy) {
			case 'explode':
				return implode(',', $value);
			case 'json':
				return json_encode($value);
			case 'serialize':
				return serialize($value);
		}

		return $value;
	}
761576
public function encodeUtf8Words($value)
    {
        $words = explode(' ', $value);
        $encoded = array();
        foreach ($words as $word) {
            $encoded[] = $this->encodeUtf8Word($word);
        }
        return join($this->encodeUtf8Word(' '), $encoded);
    }
683270
public function makeArrayFieldValue($value)
    {
        $value = $this->_unserializeValue($value);
        if (!$this->_isEncodedArrayFieldValue($value)) {
            $value = $this->_encodeArrayFieldValue($value);
        }

        return $value;
    }
82388
public static function encode($value, $options = null)
    {
        if ($options === null) {
            $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT;
        }

        $json = json_encode($value, $options);

        static::handleJsonError(json_last_error());

        return $json;
    }
1286349
protected function encodeArray(array $value)
    {
        $text = '';
        foreach ($value as $key => $value) {
            $value = (string) $value;
            $value = trim($value);

            $text .= "\n\t" . ucfirst($key) . ': ' . str_replace("\n", "\n\t\t", $value);
        }

        return $text;
    }
1030224
private function encodeLayersInformation($layers, Encoder $encoder)
    {
        $prepared = '';

        foreach ($layers as $layer) {
            if ($prepared) {
                $prepared .= ', ';
            }

            $prepared .= sprintf(
                '%s: %s',
                $encoder->encodeValue($layer->getLabel()),
                $encoder->encodeReference($layer)
            );
        }

        return '{' . $prepared . '}';
    }
663893
public function encode($value, int $options = null, int $depth = null): string
    {
        list($json, $error) = $this->softEncode($value, $options, $depth);
        if ($error !== null) {
            throw $error;
        }
        return $json;
    }
33550
function (value, strategy, e) {
      var pre = this.getTextFromHeadToCaret();
      var post = this.el.value.substring(this.el.selectionEnd);
      var newSubstr = strategy.replace(value, e);
      var regExp;
      if (typeof newSubstr !== 'undefined') {
        if ($.isArray(newSubstr)) {
          post = newSubstr[1] + post;
          newSubstr = newSubstr[0];
        }
        regExp = $.isFunction(strategy.match) ? strategy.match(pre) : strategy.match;
        pre = pre.replace(regExp, newSubstr);
        this.$el.val(pre + post);
        this.el.selectionStart = this.el.selectionEnd = pre.length;
      }
    }
828727
public function deleteConditionStrategy(string $strategy, array $parameters = []): Model
    {
        if ( ! array_has($this->main, 'delete_condition')) {
            $this->main['delete_condition'] = '';
        }

        $this->main['delete_condition'] .= ($this->main['delete_condition'] ? '|' : '') . $strategy;

        if (count($parameters)) {

            $serializedParameters = implode(
                ',',
                array_map(
                    function ($value) {
                        return (string) $value;
                    },
                    $parameters
                )
            );

            $this->main['delete_condition'] .= ':' . $serializedParameters;
        }

        return $this;
    }
1035376
public function url($value, array $options, $mode) {
        if ($mode === self::TO && $options['encode']) {
            return urlencode($value);
        }

        if ($mode === self::FROM && $options['decode']) {
            return urldecode($value);
        }

        return $value;
    }
1321498
protected function getCommand(StrategyInterface $strategy)
    {
        $command = $strategy->get();
        if ($command === null) {
            throw new Exception('Failed to locate a sensible command');
        }

        return $command;
    }
984258
public function convertFromUrlEncode($value)
    {
        $converted = urldecode($value);
        if (!$converted || $converted === $value) {
            return $value;
        } else {
            return $value . "\n" . $converted;
        }
    }
336655
protected function encodeField(&$value, &$offset)
    {
        if (null !== $value && !is_numeric($value)) {
            $value = mb_convert_encoding((string) $value, $this->output_encoding, $this->input_encoding);
        }

        if (!is_numeric($offset)) {
            $offset = mb_convert_encoding((string) $offset, $this->output_encoding, $this->input_encoding);
        }
    }
991584
public static function encode($value, string $type = null): string
    {
        return self::run(self::ENCODER, $value, $type);
    }
808056
protected function getPasswordHashingStrategyAndIdentifier($strategyIdentifier = 'default')
    {
        if (isset($this->passwordHashingStrategies[$strategyIdentifier])) {
            return [$this->passwordHashingStrategies[$strategyIdentifier], $strategyIdentifier];
        }

        if ($strategyIdentifier === 'default') {
            if (!isset($this->strategySettings['default'])) {
                throw new MissingConfigurationException('No default hashing strategy configured', 1320758427);
            }
            $strategyIdentifier = $this->strategySettings['default'];
        }

        if (!isset($this->strategySettings[$strategyIdentifier])) {
            throw new MissingConfigurationException('No hashing strategy with identifier "' . $strategyIdentifier . '" configured', 1320758776);
        }
        $strategyObjectName = $this->strategySettings[$strategyIdentifier];
        $this->passwordHashingStrategies[$strategyIdentifier] = $this->objectManager->get($strategyObjectName);
        return [$this->passwordHashingStrategies[$strategyIdentifier], $strategyIdentifier];
    }
285289
private function encode($value)
    {
        if ($value === true)
            $value = "true";
        else if ($value === false)
            $value = "false";
        else if (is_string($value))
            $value = "\"$value\"";
        return $value;
    }
1225285
public function rawurl($value, array $options, $mode) {
        if ($mode === self::TO && $options['encode']) {
            return rawurlencode($value);
        }

        if ($mode === self::FROM && $options['decode']) {
            return rawurldecode($value);
        }

        return $value;
    }