Normalise options

@param  array $options Options to override the defaults
@return array
329698
protected function normalizeOptions(array $options)
    {
        return array_merge(parent::normalizeOptions($options), [
            'inverse'   => $this->inverse,
            'fixed'     => $this->fixed,
            'static'    => $this->static,
            'brand'     => $this->brand,
            'useForm'   => $this->useForm,
            'rightMenu' => $this->rightMenu,
            ], $options);
    }
149356
public function setOptions( array $options )
    {
        foreach ( $this->defaults as $option => $defaults ) {
            $this->values[$option] = ( array_key_exists($defaults['name'], $options) ) ? $options[$option] : $defaults['default'];
        }
    }
407210
protected function resolveFieldOptionValues(array $options)
    {
        foreach ($options as &$value) {
            if (!is_array($value)) {
                continue;
            }
            if (is_callable($value)) {
                $value = $value();

                continue;
            }

            $value = $this->resolveFieldOptionValues($value);
        }

        unset($value);

        return $options;
    }
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;
    }
1223874
public function setOptions(array $options)
	{
		$base_options = array(
			'NODE_PATH' => 'node',
			'NPM_PATH' => __DIR__ . '/../../node_modules/',
			'CACHE_DIRECTORY' => 'cache/',
		);

		foreach ($base_options as $key => $default)
		{
			if (isset($options[$key]))
			{
				$this->options[$key] = $options[$key];
				unset($options[$key]);
			}
			else
				$this->options[$key] = $default;
		}

		return $options;
	}
303981
protected function _cleanOptions($options) {
		if (!isset($options['size']) || empty($options['size']) || !is_numeric($options['size'])) {
			unset($options['size']);
		} else {
			$options['size'] = min(max($options['size'], 1), 512);
		}

		if (!$options['rating'] || !in_array(mb_strtolower($options['rating']), $this->_allowedRatings)) {
			unset($options['rating']);
		}

		if (!$options['default']) {
			unset($options['default']);
		} else {
			if (!in_array($options['default'], $this->_defaultIcons) && !Validation::url($options['default'])) {
				unset($options['default']);
			}
		}
		return $options;
	}
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);
    }
612143
protected function getOptions(array  $options): array
    {
        $options['format'] = array_get($options, 'format', $this->format);
        $options['locale'] = array_get($options, 'locale', config('app.locale'));

        return $options;
    }
859487
private function parseOptions(array $options)
    {
        if (isset($options['headers']) && is_array($options['headers'])) {
            $this->headers = $options['headers'];
        }

        if (isset($options['scheme']) && strtolower($options['scheme']) === 'http') {
            $this->scheme = 'http';
        }

        if (isset($options['output_format']) && strtolower($options['output_format']) === 'xml') {
            $this->outputFormat = 'xml';
        }
    }
605774
public function prepareOptions(array $options)
    {
        $optionPieces = [];
        foreach ($options as $opt => $value) {
            //if it's an array of options, throw them in there as well
            if (is_array($value)) {
                foreach ($value as $optArrayValue) {
                    $optionPieces[] = '--'.$opt.'="'.addslashes($optArrayValue).'"';
                }
            } else {
                $option = null;

                //option exists with no value
                if (is_numeric($opt)) {
                    $option = $value;
                } elseif (!empty($value)) {
                    $option = $opt.'="'.addslashes($value).'"';
                }

                if (!is_null($option)) {
                    $optionPieces[] = '--'.$option;
                }
            }
        }

        return implode(' ', $optionPieces);
    }
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;
    }
1184674
protected function setDefaultOptions(array $options=[])
	{
		$this->defaultOptions = [
			'foreign_key' => $this->model->getForeignKey(),
			'primary_key' => $this->model->getKeyName()
		];
	}
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".');
        }
    }
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;
    }
1076334
public static function normalize($options)
    {
        //normalize not indexed fields
        foreach ($options as $key => $value) {
            if (\is_int($key)) {
                if (!isset($options[$value])) {
                    $options[$value] = true;
                }
                unset($options[$key]);
            }
        }

        //normalize comma separated names
        foreach ($options as $fieldsNames => $option) {
            if (strpos($fieldsNames, ',') !== false) {
                $fieldNamesArray = explode(',', $fieldsNames);
                foreach ($fieldNamesArray as $name) {
                    $name = trim($name);
                    if (!isset($options[$name])) {
                        $options[$name] = $option;
                        unset($options[$fieldsNames]);
                    }
                }
            }
        }

        return $options;
    }
615453
protected function setDefaultOptions(array $options = [])
    {
        $this->options = $this->formHelper->mergeOptions($this->allDefaults(), $this->getDefaults());
        $this->options = $this->prepareOptions($options);

        $defaults = $this->setDefaultClasses($options);
        $this->options = $this->formHelper->mergeOptions($this->options, $defaults);

        $this->setupLabel();
    }
1062934
public static function prepareOptions(array $options) : array
    {
        if (empty($options['fields'])) {
            return [];
        }

        $result = [];
        foreach ($options['fields'] as $field => $params) {
            if (empty($params['column']) && empty($params['default'])) {
                continue;
            }

            $result['fields'][$field] = $params;
        }

        return $result;
    }