The specified formatting options are merged with the default values.

@param array $options

@return array
554106
private function getMergedOptions(array $options)
    {
        $options = array_merge(
            $this->getDefaultOptions(),
            $options
        );

        if (isset($options['formats'])) {
            $options['formats'] = self::mergeFormats($this->getDefaultFormats(), $options['formats']);
        } else {
            $options['formats'] = $this->getDefaultFormats();
        }

        if (is_null($options['line_ending'])) {
            $options['line_ending'] = $options['type'] === 'html' ? '<br/>' : "\n";
        }

        if (is_null($options['indentation'])) {
            $options['indentation'] = $options['type'] === 'html' ? '&nbsp;&nbsp;&nbsp;&nbsp;' : '    ';
        }

        // `parts_newline` requires `clause_newline`
        $options['parts_newline'] &= $options['clause_newline'];

        return $options;
    }
73696
public static function ExtendOptions(array $options = [])
    {
        $options = array_merge( [
            'width'=>null,
            'height'=>null,

            'focusX'=>0,
            'focusY'=>0,

            'resize'=>false,
        ], $options );

        // Format to strings
        $options['width'] = $options['width'] ?: '_';
        $options['height'] = $options['height'] ?: '_';

        return $options;
    }
986564
private function parseOptions($options)
    {
        if (empty($options)) return [];

        foreach ($options as $option) {
            if (str_contains($option, '(')) {
                preg_match('/([a-z]+)\(([^\)]+)\)/i', $option, $matches);

                $results[$matches[1]] = $matches[2];
            } else {
                $results[$option] = true;
            }
        }

        return $results;
    }
1322756
protected function getPrestaShopOptions(array $options)
    {
        $result = array(
            'query' => array(),
            'id' => 'id',
            'name' => 'name',
        );

        foreach ($options as $value => $label) {
            $result['query'][] = array(
                'id' => $value,
                'name' => $label,
            );
        }

        return $result;
    }
23630
protected function parseOptions(array $options): array
    {
        $this->setTransformer(new StringToBooleanTransformer());

        $options = parent::parseOptions($options);

        // Set some default CSS classes if chosen theme is "bootstrap".
        if (isset($options['theme']) && 'bootstrap' === $options['theme']) {
            $options['attributes']['class'] = isset($options['attributes']['class']) ?
                'form-check-input '.$options['attributes']['class'] : 'form-check-input';
            $options['label_attr']['class'] = isset($options['label_attr']['class']) ?
                'form-check-label '.$options['label_attr']['class'] : 'form-check-label';
        }

        return $options;
    }
1123359
protected function mergeOptions(array $options)
    {
        $merged = [];
        foreach ($this->supportedOptions() as $option) {
            $merged[$option] = $this->mergeOption($option, $options);
        }

        return $merged;
    }
527556
protected function getFilteredOptions(array $options)
    {
        $default = $this->getDefaultOptions();
        $options = \array_merge($default, $options);

        $uses = \array_unique(\array_merge([
            'path', 'filename', 'extension', 'format',
        ], \array_keys($default)));

        $data = Arr::only($options, $uses);

        return $data;
    }
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;
  }
1084160
protected function prepareBCOptions(array $options)
    {
        $options = (array) Arr::def($options, 'charset', static::$defaultCharset);
        $options = (array) Arr::def(
            $options,
            'collate',
            static::$defaultCharset === static::CHARSET_UTF8 ? 'utf8_unicode_ci' : 'utf8mb4_unicode_ci'
        );

        return $options;
    }
1125640
protected function getOptions(array $options)
    {
        $labels = [];
        if ($this->hasLanguages()) {
            // As this point we are construction the options for multiple languages
            foreach ($this->languages as $language) {
                foreach ($options as $key => $option) {
                    $labels[$language][$key] = Helpers::convertNameToLabel($option);
                }
            }
        } else {

            // At this point we are just formatting the labels
            foreach ($options as $key => $option) {
                $labels[$key] = Helpers::convertNameToLabel($option);
            }
        }

        return $labels;
    }
470764
protected function _initializationOptions($options = array()) {
		$defaults = array(
			'_buffer' => true,
			'_css' => true,
			'_cssText' => true,
			'_scripts' => true,
			'_scriptBlock' => false,
			'_editor' => true,
			'_inline' => true,
		);

		return json_encode(array_diff_key(array_merge(
			$defaults,
			(array)$options
		), $defaults));
	}
990761
public function format($number, $options = [])
    {
        return $this->formatter()->format($number,
            $this->mergeOptions($options)
        );
    }
650186
public function formatter(Option $option)
    {
        $lines = [];
        $options = [];
        $span = 30;
        foreach ($option->getDefinitions() as $define) {
            $key = '--' . $define->getName();
            if ($define->hasShortName()) {
                $key .= ',-' . $define->getShortName();
            }
            if ($define->hasDefault()) {
                $default = $define->getDefault();
                switch (true) {
                    case is_bool($default):
                        $value = '';
                        break;
                    default:
                        $value = '=' . $default;
                        break;
                }
                $key .= $value;
            }
            $options[$key] = $define->isRequired() ?
                '(required) ' . $define->getDescription() : $define->getDescription();

            // compare key length.
            if (mb_strwidth($key) > $span) $span = mb_strwidth($key);
        }

        foreach ($options as $key => $value) {
            $diff = strlen($key) - mb_strwidth($key, $this->encoding);
            $lines[] = sprintf("%s  %s", str_pad($key, $span + $diff), $value);
        }

        return join(PHP_EOL, $lines);
    }
102799
private static function adjustOptions(array $options) {
        $result = [];

        foreach($options as $key => $value) {
            $result[str_replace("-", "_", $key)] = $value;
        }

        return $result;
    }
1115820
private function mergeOptions(array $options)
    {
        /** @var Option[] $mergedList */
        $mergedList = array_merge($this->optionList, $options);
        $duplicates = array();
        foreach ($mergedList as $option) {
            foreach ($mergedList as $otherOption) {
                if (($option === $otherOption) || in_array($otherOption, $duplicates)) {
                    continue;
                }
                if ($this->optionsConflict($option, $otherOption)) {
                    throw new \InvalidArgumentException('Failed to add options due to conflict');
                }
                if (($option->short() === $otherOption->short()) && ($option->long() === $otherOption->long())) {
                    $duplicates[] = $option;
                }
            }
        }
        foreach ($mergedList as $index => $option) {
            if (in_array($option, $duplicates)) {
                unset($mergedList[$index]);
            }
        }
        $this->optionList = array_values($mergedList);
    }
1102245
public function prepareOptions($options)
    {
        $defaultOptions = [
            'requirements' => [],
            'options' => [],
            'host' => null,
            'scheme' => null,
            'port' => null,
            'sslPort' => null,
            'extra' => [],
        ];

        return array_merge($defaultOptions, (array) $options);
    }
1011618
protected function normalizeOptions($options)
    {
        $result = array();
        foreach ($options as $name => $value) {
            $result[] = "--$name=\"$value\"";
        }
        return implode(' ', $result);
    }