Resolve options

@param  array  $options
@return Options
333198
protected function resolveOptions(array $options = array())
    {
        $resolver = new OptionsResolver;
        $this->setDefaultOptions($resolver);

        if (!empty($this->options)) {
            $resolver->setDefaults($this->options);
        }

        return $resolver->resolve($options);
    }
828143
private function sanitizeOptions(array $options)
    {
        $resolver = new OptionsResolver();
        $resolver->setDefault('axis', 'x');
        $resolver->setAllowedValues('axis', ['x', 'horizontal', 'y', 'vertical']);
        $resolver->setNormalizer('axis', function (Options $options, $value) {
            return 'horizontal' === $value ? 'x' : ('vertical' === $value ? 'y' : $value);
        });

        try {
            return $resolver->resolve($options);
        } catch (ExceptionInterface $e) {
            throw new InvalidArgumentException('The "axis" option must be set to "x", "horizontal", "y", or "vertical".');
        }
    }
857331
protected function configureOptions(array $options)
    {
        $resolver = new OptionsResolver();

        $resolver->setDefaults([
            'adapter'          => null,
            'secure'           => true,
            'host'             => self::TMDB_URI,
            'base_url'         => null,
            'token'            => null,
            'session_token'    => null,
            'event_dispatcher' => array_key_exists('event_dispatcher', $this->options) ? $this->options['event_dispatcher'] : new EventDispatcher(),
            'cache'            => [],
            'log'              => [],
        ]);

        $resolver->setRequired([
            'adapter',
            'host',
            'token',
            'secure',
            'event_dispatcher',
            'cache',
            'log'
        ]);

        $resolver->setAllowedTypes('adapter', ['object', 'null']);
        $resolver->setAllowedTypes('host', ['string']);
        $resolver->setAllowedTypes('secure', ['bool']);
        $resolver->setAllowedTypes('token', ['object']);
        $resolver->setAllowedTypes('session_token', ['object', 'null']);
        $resolver->setAllowedTypes('event_dispatcher', ['object']);

        $this->options = $resolver->resolve($options);

        $this->postResolve($options);

        return $this->options;
    }
860390
protected function fixOptions(array $options = []) : array
    {
        $result = $options;
        if (empty($result)) {
            return $result;
        }

        if (empty($result['fieldDefinitions'])) {
            return $result;
        }

        if (!is_array($result['fieldDefinitions'])) {
            return $result;
        }

        // Sometimes, when setting fieldDefinitions manually to render a particular
        // type, the name is omitted.  This works for an array, but doesn't work for
        // the CsvField instance, as the name is required.  Gladly, we know the name
        // and can fix it easily.
        if (empty($result['fieldDefinitions']['name'])) {
            $result['fieldDefinitions']['name'] = $this->config->getField();
        }

        // Previously, fieldDefinitions could be either an array or a CsvField instance.
        // Now we expect it to always be a CsvField instance.  So, if we have a non-empty
        // array, then instantiate CsvField with the values from it.
        $result['fieldDefinitions'] = new CsvField($result['fieldDefinitions']);

        return $result;
    }
103617
public function getIdFromOptions(array $options) : string
    {
        $optionsResolver = new OptionsResolver();
        $optionsResolver->setRequired('id');

        $options = $optionsResolver->resolve($options);

        return $options['id'];
    }
551467
private function options(array $options = [])
    {
        $options['query'] = array_merge(
            [
                'protover' => $this->api_protover,
                'clientver' => $this->app_version,
                'client' => $this->app_client,
            ],
            isset($options['query']) ? $options['query'] : []
        );

        $options['headers'] = array_merge(
            [
                'User-Agent' => $this->app_code,
            ],
            isset($options['headers']) ? $options['headers'] : []
        );

        return $options;
    }
1258219
public function addOptions(array $options)
    {
        foreach ($options as $name => $value) {
            $this->setOption($name, $value);
        }

        return $this;
    }
566791
protected function parseOptions(array $options)
    {
        $request = $this->requestStack->getCurrentRequest();
        if (!empty($request) && $request->isSecure()) {
            $options['recommenderEndPoint'] = str_replace('http://', 'https://', $options['recommenderEndPoint']);
        }

        return $options;
    }
550632
public function addOptions(array $options)
    {
        foreach ($options as $name => $defaultValue) {
            $this->addOption($name, $defaultValue);
        }

        return $this;
    }
1049001
private function prepareOptions(array $options){
        if (!Arr::has($options, 'method')) {
            Arr::set($options, 'method', 'post');
        }

        if (!Arr::has($options, 'action')) {
            Arr::set($options, 'action', '');
        }

        return $options;
    }
789611
protected function handleOptions(array $options = [])
    {
        foreach ($options as $option => $value) {
            if (null === $value) {
                unset($options[$option]);
                continue;
            }

            if (!empty($value) && array_key_exists($option, $this->optionsWithContentCheck)) {
                $saveToTempFile = !$this->isFile($value) && !$this->isOptionUrl($value);
                $fetchUrlContent = $option === 'xsl-style-sheet' && $this->isOptionUrl($value);

                if ($saveToTempFile || $fetchUrlContent) {
                    $fileContent = $fetchUrlContent ? file_get_contents($value) : $value;
                    $options[$option] = $this->createTemporaryFile($fileContent, $this->optionsWithContentCheck[$option]);
                }
            }
        }

        return $options;
    }
973881
public function mergeUserOptions(array $options) {
    foreach ($options as $option=>$value)
      $this->_options[$option] = $value;
    return $this;
  }
1233122
private function getRequestOptions(array $options)
    {
        $restOptions = isset($options['restOptions'])
            ? $options['restOptions']
            : $this->restOptions;
        $timeout = isset($options['requestTimeout'])
            ? $options['requestTimeout']
            : $this->requestTimeout;

        if ($timeout && !array_key_exists('timeout', $restOptions)) {
            $restOptions['timeout'] = $timeout;
        }

        return $restOptions;
    }
1083875
protected function resolveOptions(array $config): array
    {
        $optionsResolver = new OptionsResolver();

        $optionsResolver->setDefault('name', null);
        $optionsResolver->setDefault('type', null);
        $optionsResolver->setDefault('options', []);
        $optionsResolver->setDefault('parent', null);

        $optionsResolver->setRequired(['name', 'type', 'options', 'parent']);

        $optionsResolver->setAllowedTypes('name', ['null', 'string']);
        $optionsResolver->setAllowedTypes('type', ['null', 'string', ParameterTypeInterface::class]);
        $optionsResolver->setAllowedTypes('options', 'array');
        $optionsResolver->setAllowedTypes('parent', ['null', ParameterBuilderInterface::class]);

        $optionsResolver->setNormalizer(
            'type',
            function (Options $options, $value) {
                if (!is_string($value)) {
                    return $value;
                }

                return $this->parameterTypeRegistry->getParameterTypeByClass($value);
            }
        );

        return $optionsResolver->resolve($config);
    }
494128
public function resolveOptions(array $options)
    {
        $resolver = new OptionsResolver();
    
        $resolver->setRequired(array(
            'search', 'filters', 'page', 'orderBy', 'sort', 'records', 'masterGridRowId'
        ));
    
        $resolver->setAllowedTypes(array(
            'page' => array('int'),
            'orderBy' => array('string', 'bool'),
            'sort' => array('string'),
            'records' => array('int'),
            'search' => array('bool'),
            'filters' => array('array', 'bool'),
            'masterGridRowId' => array('int')
        ));
    
        $resolver->setAllowedValues(array(
            'sort' => array('ASC', 'DESC')
        ));
    
        $resolver->setDefaults(array(
            'search'          => false,
            'filters'         => false,
            'page'            => 0,
            'orderBy'         => false,
            'sort'            => 'ASC',
            'records'         => 0,
            'masterGridRowId' => 0
        ));
    
        $this->options = $resolver->resolve($options);
        
        return $this;
    }
482336
public function setOptions(array $options)
    {
        foreach ($options as $option => $value) {
            if (property_exists($this, $option)) {
                $this->{$option} = $value;
            }
        }

        return $this;
    }
392839
protected function parseOptions(array $options)
    {
        $options = array_merge($this->defaultOptions, $options);

        foreach ($options as $option => $value) {
            if (! in_array($option, $this->allowedOptions, true)) {
                throw new \InvalidArgumentException("Option [$option] is not allowed.");
            }
        }

        return $options;
    }