@param \Algolia\AlgoliaSearch\RequestOptions\RequestOptions|array $options
@param array                                                      $defaults

@return \Algolia\AlgoliaSearch\RequestOptions\RequestOptions
494828
public function create($options, $defaults = array())
    {
        if (is_array($options)) {
            $options += $defaults;
            $options = $this->format($options);
            $options = $this->normalize($options);

            $options = new RequestOptions($options);
        } elseif ($options instanceof RequestOptions) {
            $defaults = $this->create($defaults);
            $options->addDefaultHeaders($defaults->getHeaders());
            $options->addDefaultQueryParameters($defaults->getQueryParameters());
            $options->addDefaultBodyParameters($defaults->getBody());
        } else {
            throw new \InvalidArgumentException(
                'RequestOptions can only be created from array or from RequestOptions object'
            );
        }

        return $options->addDefaultHeaders($this->config->getDefaultHeaders());
    }
925188
public function setOptions(array $options)
    {
        foreach ($options as $opt => $val) {
            $this->setOption($opt, $val);
        }

        return $this;
    }
614723
protected function getResourceMethods($defaults, $options)
    {
        $methods = $defaults;

        if (isset($options['only'])) {
            $methods = array_intersect($methods, (array) $options['only']);
        }

        if (isset($options['except'])) {
            $methods = array_diff($methods, (array) $options['except']);
        }

        return $methods;
    }
858455
public function setOptions(array $options)
    {
        $defaultOptions = [
            'primary' => false,
            'auto_increment' => false,
            'position' => null,
            'length' => null,
        ];

        $options = array_merge($defaultOptions, $options);

        if ($options['primary']) {
            $options['auto_increment'] = true;

            $this->signed = false;
            $this->allowNull = false;
        }

        $this->autoIncrement = $options['auto_increment'];
        $this->position = $options['position'];
        $this->length = $options['length'];
        $this->primary = $options['primary'];

        return $this;
    }
146904
public function setCurlOptions(array $options) {
        return new Request([
            'method'              => $this->method,
            'url'                 => $this->url,
            'curlOptions'         => $options,
            'query'               => $this->query,
            'payload'             => $this->payload,
            'expectedStatusCodes' => $this->expectedStatusCodes
        ]);
    }
836711
private function createMax(array $defaults): Max
    {
        $options = ['max' => $defaults['max']];

        if (array_key_exists('maxMessage', $defaults)) {
            $options['message'] = $defaults['maxMessage'];
        }

        return new Max($options);
    }
500092
public function addFields($fields = [], $defaults = [])
    {
        foreach ($fields as $field) {
            if (is_string($field)) {
                $this->addField($field, $defaults);
                continue;
            }

            if (is_array($field) && isset($field[0])) {
                $name = $field[0];
                unset($field[0]);
                $this->addField($name, $field);
                continue;
            }
        }

        return $this;
    }
446404
public function withOptions($options)
    {
        if (is_array($options)) {
            $options = new RequestOptions($options);
        }

        $this->options = $options;

        return $this;
    }
780270
public function configureDefaults(array $defaults, $force = false)
    {
        if ($force || empty($this->toArray())) {
            $attachmentDefaults = $this->attachmentDefaults;

            foreach (MessageDefaults::allKeys() as $key) {
                if (isset($defaults[$key]) && ! is_null($value = $defaults[$key])) {
                    if (strpos($key, 'attachment_') !== false) {
                        if ($key = substr($key, strlen('attachment_'))) {
                            $attachmentDefaults[$key] = $value;
                        }
                    } else {
                        $this->fillDefaults($key, $value);
                    }
                }
            }

            $this->setAttachmentDefaults($attachmentDefaults);
        }

        return $this;
    }
52196
protected function mergeDefaults(array $params, array $defaults): array
    {
        foreach ($params as $key => $value) {
            if (!\is_int($key) && null !== $value) {
                $defaults[$key] = $value;
            }
        }

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

        $this->options = array_merge($this->getDefaults(), $options);
        return $this;
    }
1301585
public function defaults(array $defaults = [])
    {
        $definition = $this->getDefinition();

        foreach ($defaults as $name => $default) {
            if ($definition->hasArgument($name)) {
                $input = $definition->getArgument($name);
            } elseif ($definition->hasOption($name)) {
                $input = $definition->getOption($name);
            } else {
                throw new \InvalidArgumentException(
                    "Unable to set default for [{$name}]. It does not exist as an argument or option."
                );
            }

            $input->setDefault($default);
        }

        return $this;
    }
1184674
protected function setDefaultOptions(array $options=[])
	{
		$this->defaultOptions = [
			'foreign_key' => $this->model->getForeignKey(),
			'primary_key' => $this->model->getKeyName()
		];
	}
700587
public function setDefaultView($defaultView, $options)
    {
        $this->defaultView = $defaultView;
        $this->defaultViewOptions = $options;
        return $this;
    }
1264288
protected function setOptions($options = [])
    {
        $myProperties = get_class_vars(__CLASS__);
        $myDefaults = $myProperties['DEFAULTS'];
        $defaults = array_replace_recursive($myDefaults, $this->DEFAULTS);

        if (empty($this->rootPath)) {
            $this->rootPath = realpath($this->getChildDir()) . '/';
        }

        $defaults['description']['jsonPath'] = realpath($this->rootPath . $this->DEFAULT_API_JSON_PATH);
        $mergedOptions = array_replace_recursive($defaults, $options);
        $parsedOptions = $this->parseOptions($mergedOptions, $mergedOptions);

        $handlers = $this->getStacks($parsedOptions);
        if (!empty($handlers)) {
            if (empty($parsedOptions['client'])) {
                $parsedOptions['client'] = [];
            }
            $parsedOptions['client']['handler'] = $handlers;
        }

        $this->options = $parsedOptions;

        return $this;
    }
1256210
protected function promptOptions(array $choices, $default): self
    {
        $options = '';

        foreach ($choices as $choice) {
            $style    = \in_array($choice, (array) $default) ? 'boldCyan' : 'cyan';
            $options .= "/<$style>$choice</end>";
        }

        $options = \ltrim($options, '/');

        $this->writer->colors(" ($options): ");

        return $this;
    }
1356102
public static function get($name, $options = [])
    {
        $default = isset($options["default"]) ? $options["default"] : null;

        return isset($_REQUEST[$name]) ? $_REQUEST[$name]: $default;
    }