@param array $defaultOptions

@return array
491346
public function getOptions(array $defaultOptions = []): array
    {
        $options = $this->options;
        $options['TTL'] = array_key_exists('TTL', $options) ? $options['TTL'] : $defaultOptions['TTL'];
        $options['urgency'] = array_key_exists('urgency', $options) ? $options['urgency'] : $defaultOptions['urgency'];
        $options['topic'] = array_key_exists('topic', $options) ? $options['topic'] : $defaultOptions['topic'];

        return $options;
    }
1093968
protected function calculateOptions(array $userOptions): array
    {
        foreach ($this->template as $property => $pattern) {
            if (isset($userOptions[$property])) {
                //Specified by user
                continue;
            }

            if (!is_string($pattern)) {
                //Some options are actually array of options
                $userOptions[$property] = $pattern;
                continue;
            }

            //Let's create option value using default proposer values
            $userOptions[$property] = \Spiral\interpolate(
                $pattern,
                $this->proposedOptions($userOptions)
            );
        }

        return $userOptions;
    }
403191
protected function getPdoOptions(array $options)
    {
        $result = $this->pdoDefaultOptions;

        foreach ($options as $k => $v)
        {
            $result[$k] = $v;
        }

        return $result;
    }
1152799
protected function getDefaultOptions($config)
    {
        $defaultOptions = (
            isset($config['defaults']) &&
            is_array($config['defaults']) &&
            isset($config['defaults']['options']) &&
            is_array($config['defaults']['options'])
        )
            ? $config['defaults']['options']
            : [];

        return $defaultOptions;
    }
1168720
public function setOptions($options = [])
    {
        if (!is_array($options)) {
            $options = [];
        }

        $this->options = array_merge($this->getDefaults(), $options);
        return $this;
    }
1102245
public function prepareOptions($options)
    {
        $defaultOptions = [
            'requirements' => [],
            'options' => [],
            'host' => null,
            'scheme' => null,
            'port' => null,
            'sslPort' => null,
            'extra' => [],
        ];

        return array_merge($defaultOptions, (array) $options);
    }
53598
public function getFormOptions($options = []) {
		if (empty($options) || !is_array($options)) {
			$options = [];
		}

		$optionsDefault = $this->_getOptionsForElem('form');
		$result = $optionsDefault + $options;

		return $result;
	}
375932
private function resolveOptions(array $options = array())
    {
        $this->options["seo"] = $this->seo;

        if (!$this->seo->getTitle() && $options['defaultTitle']) {
            $this->seo->setTitle($options['defaultTitle']);
        }

        if (!$this->seo->getTitle() && $options['defaultKeywords']) {
            $this->seo->setTitle($options['defaultKeywords']);
        }

        if (!$this->seo->getTitle() && $options['defaultDescription']) {
            $this->seo->setTitle($options['defaultDescription']);
        }

        return array_merge($this->options, $options);
    }
364419
private static function _getOptions($options, $default)
    {
        if (is_array($options)) {
            foreach ($default as $key => $value) {
                if (isset($options[$key])) {
                    $default[$key] = $options[$key];
                }
            }
        }

        return $default;
    }
1334809
protected function getUrlOptionsFromConfig(
        $urlConfig,
        array $defaultOptions
    ) {
        $urlOptions = (
            is_array($urlConfig) &&
            isset($urlConfig[2]) &&
            is_array($urlConfig[2])
        )
            ? $urlConfig[2]
            : [];

        return array_merge(
            $defaultOptions,
            $urlOptions
        );
    }
46655
protected function setDefaultOptions(array $options=[])
    {
        $tables = [
            'model' => $this->model->getTable(),
            'toModel' => $this->toModel->getTable()
        ];

        asort($tables, SORT_REGULAR);
        $pivotTable = implode('_', array_map([Str::class, 'singular'], $tables));
        
        $this->defaultOptions = [
            'pivot_table' => $pivotTable,
            'foreign_key' => $this->model->getForeignKey(),
            'related_key' => $this->toModel->getForeignKey(),
            'relation' => $this->toModel->getTable()
        ];
    }
1120609
protected function setDefaults(array $defaultOptions = array())
    {
        $defaultOptions = array_merge(array(
            'depth' => null,
            'ancestorCurrencyDepth' => null,
            'currentClass' => 'active',
            'ancestorClass' => 'active',
            'firstClass' => null,
            'lastClass' => null
        ), $defaultOptions);

        parent::setDefaults($defaultOptions);
    }
7048
protected function _setDefaultOptions($options)
    {
        if (!is_array($options)) {
            Zend_Cache::throwException('default_options must be an array !');
        }
        foreach ($options as $key=>$value) {
            if (!is_string($key)) {
                Zend_Cache::throwException("invalid option [$key] !");
            }
            $key = strtolower($key);
            if (isset($this->_specificOptions['default_options'][$key])) {
                $this->_specificOptions['default_options'][$key] = $value;
            }
        }
    }
568852
function defaults(options, defaultOptions) {
  options || (options = {});

  for (var opt in defaultOptions) {
    if (defaultOptions.hasOwnProperty(opt) && !options.hasOwnProperty(opt)) {
      options[opt] = defaultOptions[opt];
    }
  }

  return options;
}
1207700
private static function getDefaults()
    {
        return [
            self::OPTION_ENDPOINT           => null,
            self::OPTION_HOST               => null,
            self::OPTION_PORT               => DefaultValues::DEFAULT_PORT,
            self::OPTION_TIMEOUT            => DefaultValues::DEFAULT_TIMEOUT,
            self::OPTION_CREATE             => DefaultValues::DEFAULT_CREATE,
            self::OPTION_UPDATE_POLICY      => DefaultValues::DEFAULT_UPDATE_POLICY,
            self::OPTION_REPLACE_POLICY     => DefaultValues::DEFAULT_REPLACE_POLICY,
            self::OPTION_DELETE_POLICY      => DefaultValues::DEFAULT_DELETE_POLICY,
            self::OPTION_REVISION           => null,
            self::OPTION_WAIT_SYNC          => DefaultValues::DEFAULT_WAIT_SYNC,
            self::OPTION_BATCHSIZE          => null,
            self::OPTION_JOURNAL_SIZE       => DefaultValues::DEFAULT_JOURNAL_SIZE,
            self::OPTION_IS_SYSTEM          => false,
            self::OPTION_IS_VOLATILE        => DefaultValues::DEFAULT_IS_VOLATILE,
            self::OPTION_CLIENT             => DefaultValues::DEFAULT_CLIENT,
            self::OPTION_TRACE              => null,
            self::OPTION_ENHANCED_TRACE     => false,
            self::OPTION_AUTH_USER          => null,
            self::OPTION_AUTH_PASSWD        => null,
            self::OPTION_AUTH_TYPE          => null,
            self::OPTION_RECONNECT          => false,
            self::OPTION_BATCH              => false,
            self::OPTION_BATCHPART          => false,
            self::OPTION_CHECK_UTF8_CONFORM => DefaultValues::DEFAULT_CHECK_UTF8_CONFORM,
        ];
    }
1337371
protected function prepareDefaults($options): array
    {
        $defaults = $this->configs;

        if (! empty($defaults['headers'])) {
            // Default headers are only added if they are not present.
            $defaults['_headers'] = $defaults['headers'];
            unset($defaults['headers']);
        }

        // Special handling for headers is required as they are added as
        if (array_key_exists('headers', $options)) {
            // Allows default headers to be unset.
            if ($options['headers'] === null) {
                $defaults['_headers'] = null;
                unset($options['headers']);
            } elseif (! \is_array($options['headers'])) {
                throw new \InvalidArgumentException('headers must be an array');
            }
        }

        // Shallow merge defaults underneath options.
        $result = array_replace($defaults, $options);

        // Remove null values.
        foreach ($result as $k => $v) {
            if ($v === null) {
                unset($result[$k]);
            }
        }

        return $result;
    }
164411
protected function _setDefaultUserOptions(array $options) {
    foreach ($options as $option=>$value) {
      if (!$this->getUserOption($option))
        $this->setUserOption($option,$value);
    }
    return $this;
  }