Encodes data in Yaml format.

@param array $options - Options.

@throws EncodeException

@return string
179687
public function encode(array $options = [])
    {
        $options = array_merge(
            [
                'inline'                        => 2,
                'indent'                        => 4,
                'exceptionOnInvalidType'        => false,
                'objectSupport'                 => false
            ],
            $options
        );

        return SymfonyYaml::dump(
            $this->getContents(),
            $options['inline'],
            $options['indent'],
            $options['exceptionOnInvalidType'],
            $options['objectSupport']
        );
    }
239722
public function open($options = [])
    {
        $options['method'] = self::getMethod($options);

        $options['action'] = self::getAction($options);

        $options['accept-charset'] = 'UTF-8';

        if (isset($options['files']) && $options['files']) {
            $options['enctype'] = 'multipart/form-data';
        }

        $options = $this->attributes($options);

        return '<form'.$options.'>';
    }
560282
public static function encode($value, $options = 0)
    {
        $result = json_encode($value, (int) $options);
        // @codeCoverageIgnoreStart
        if ($result === false) {
            throw new \RuntimeException(static::$errorMessages[json_last_error()]);
        }
        // @codeCoverageIgnoreEnd

        return $result;
    }
588833
private function contextToOptions(array $options)
    {
        $optionToBitMap = [
            self::OPTION_OBJECT                    => Yaml::DUMP_OBJECT,
            self::OPTION_EXCEPTION_ON_INVALID_TYPE => Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE,
            self::OPTION_OBJECT_FOR_MAP            => Yaml::DUMP_OBJECT_AS_MAP,
            self::OPTION_MULTI_LINE_LITERAL_BLOCK  => Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK,
        ];

        $bitMaskedOption = 0;

        foreach ($optionToBitMap as $option => $bitMask) {
            if ($options[ $option ]) {
                $bitMaskedOption = $bitMaskedOption | $bitMask;
            }
        }

        return $bitMaskedOption;
    }
1205836
private function _convertOptions(array $options = [])
    {
        $converted = [];
        if (!empty($options)) {
            foreach ($options as $name => $value) {
                if (is_array($value)) {
                    if (!empty($value['AND'])) {
                        $converted[$name] = implode(self::PMP_AND, $value['AND']);
                    } else if (!empty($value['OR'])) {
                        $converted[$name] = implode(self::PMP_OR, $value['OR']);
                    } else {
                        $converted[$name] = ''; // bad params
                    }
                } elseif (is_bool($value)) {
                    $converted[$name] = $value ? 'true' : 'false';
                } else {
                    $converted[$name] = $value;
                }
            }
        }
        return $converted;
    }
837639
private function writeData(array $data, array $options)
    {
        $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
    }
508664
public function setOptions(array $options) {
    foreach ($options as $key => $value) {
      if (is_int($key)) {
        $option  = '--' . $value;
      }
      elseif (strlen($key) == 1) {
        $option = '-' . $key;
        if (!empty($value)) {
          $option .= ' ' . escapeshellarg($value);
        }
      }
      else {
        // Do not render --uri=default.
        if ($key == 'uri' && $value == 'default') {
          continue;
        }
        $option = '--' . $key;
        if (!empty($value)) {
          $option .= '=' . escapeshellarg($value);
        }
      }
      if (!in_array($option, $this->options)) {
        $this->options[] = $option;
      }
    }
    return $this;
  }
465232
public static function dump(string $filename, $data, array $options = []): bool
    {
        return file_put_contents($filename, self::encode($data, $options)) !== false;
    }
421807
public static final function init(string $name, array $options = null): EncoderInterface
    {
        switch ($name) {
            case self::NAME_JSON: return new JsonEncoder($options);
            case self::NAME_GZIP: return new GzipEncoder($options);
        }

        throw new EncoderException("Unimplemented encoder '{$name}' given");
    }
751634
protected function convertWriteConcern(array $options)
    {
        if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
            return $options;
        }

        if (isset($options['safe']) && ! isset($options['w'])) {
            $options['w'] = is_bool($options['safe']) ? (integer) $options['safe'] : $options['safe'];
            unset($options['safe']);
        }

        return $options;
    }
1261091
public function utf8($value, array $options, $mode) {
        if ($mode === self::TO && $options['encode']) {
            return utf8_encode($value);
        }

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

        return $value;
    }
677466
public static function Base64Decode ($value, $options = []) {
		$value = base64_decode($value);

		$to_encoding = isset($options['to_encoding']) ? $options['to_encoding'] : false;
		if ($to_encoding !== false) {
			$from_encoding = isset($options['from_encoding']) ? $options['from_encoding'] : static::DEFAULT_ENCODING;
			return mb_convert_encoding($value, $to_encoding, $from_encoding);
		}

		return $value;
	}
54001
protected function encodeHeaders(array $headers): string
    {
        $data = '';

        foreach ($headers as $name => $values) {
            foreach ($values as $value) {
                $data .= sprintf("%s: %s\r\n", $name, $this->encodeHeader($value));
            }
        }

        return $data;
    }
399519
private function exportTableOptions(array $options)
    {
        $optionsStr = array();

        foreach($options as $name => $option) {
            if (is_array($option)) {
                $optionsStr[] = '"' . $name . '"={' . $this->exportTableOptions($option) . '}';
            } else {
                $optionsStr[] = '"' . $name . '"="' . (string) $option . '"';
            }
        }

        return implode(',', $optionsStr);
    }
928227
public static function encode(
        $value,
        $options = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION
    ) {
        $json = \json_encode($value, $options);
        if (JSON_ERROR_NONE !== ($error = \json_last_error())) {
            throw new JsonException(\json_last_error_msg(), $error);
        }

        return $json;
    }
718521
private function contextToOptions(array $options)
    {
        $optionToBitMap = [
            self::OPTION_EXCEPTION_ON_INVALID_TYPE => Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE,
            self::OPTION_OBJECT                    => Yaml::PARSE_OBJECT,
            self::OPTION_OBJECT_FOR_MAP            => Yaml::PARSE_OBJECT_FOR_MAP,
            self::OPTION_DATE_TIME                 => Yaml::PARSE_DATETIME,
        ];

        $bitMaskedOption = 0;

        foreach ($optionToBitMap as $option => $bitMask) {
            if ($options[ $option ]) {
                $bitMaskedOption = $bitMaskedOption | $bitMask;
            }
        }

        return $bitMaskedOption;
    }
1097759
public function decode(array $options = [])
    {
        $options = array_merge(
            [
                'exceptionOnInvalidType'        => false,
                'objectSupport'                 => false,
                'objectForMap'                  => false
            ],
            $options
        );

        return SymfonyYaml::parse(
            $this->getContents(),
            $options['exceptionOnInvalidType'],
            $options['objectSupport'],
            $options['objectForMap']
        );
    }