Normalize Configurations Param

@param array $configs

@return array
194873
final public function normalizeDatabaseParams(array $configs) : array
    {
        if (empty($configs)) {
            return $configs;
        }

        /**
         * Merge User Param
         */
        $currentUserParams = array_merge($this->defaultParams, $configs);

        $toSanity = [
            self::DB_HOST => 'dbhost',
            self::DB_USER => 'dbuser',
            self::DB_NAME => 'name',
            self::DB_PASSWORD => 'dbpass',
            self::DB_DRIVER   => 'dbdriver',
            self::DB_PATH     => 'dbpath',
            self::DB_PORT     => 'dbport',
            self::DB_PREFIX   => 'dbprefix',
            self::DB_PROTOCOL => 'dbprotocol',
            self::DB_CHARSET  => 'dbcharset',
            self::DB_COLLATE  => 'dbcollate'
        ];
        foreach ($toSanity as $key => $name) {
            if ($key === $name) {
                continue;
            }
            if (!isset($currentUserParams[$key]) && isset($currentUserParams[$name])) {
                $currentUserParams[$key] = $currentUserParams[$name];
                unset($currentUserParams[$name]);
            }
        }

        // re-sanitize
        if (!isset($currentUserParams[self::DB_PASSWORD]) && isset($currentUserParams['dbpassword'])) {
            $currentUserParams[self::DB_PASSWORD] = $currentUserParams['dbpassword'];
            unset($currentUserParams['dbpassword']);
        }

        /**
         * check if port in 3306 & empty driver
         */
        if (empty($currentUserParams[self::DB_DRIVER])
            && isset($currentUserParams[self::DB_PORT])
            && abs($currentUserParams[self::DB_PORT]) === 3306
        ) {
            $currentUserParams[self::DB_DRIVER] = 'mysql';
        }
        if (empty($currentUserParams[self::DB_DRIVER])) {
            $currentUserParams[self::DB_DRIVER] = $this->defaultDriver;
        }

        if (!empty($currentUserParams[self::DB_DRIVER])) {
            $currentUserParams[self::DB_DRIVER] = $this
                ->normalizeDatabaseDriver($this->currentUserParams[self::DB_DRIVER]);
        }

        if (!empty($currentUserParams[self::DB_DRIVER])
            && $currentUserParams[self::DB_DRIVER] == 'pdo_sqlite'
        ) {
            if (empty($currentUserParams[self::DB_PATH])) {
                if (is_string($currentUserParams[self::DB_NAME])
                    && isset($currentUserParams[self::DB_NAME])
                ) {
                    $currentUserParams[self::DB_PATH] = $currentUserParams[self::DB_NAME];
                }
            } elseif (empty($currentUserParams[self::DB_NAME])) {
                if (is_string($currentUserParams[self::DB_PATH])
                    && isset($currentUserParams[self::DB_PATH])
                ) {
                    $currentUserParams[self::DB_NAME] = $currentUserParams[self::DB_PATH];
                }
            }
        }

        $charset = self::DEFAULT_CHARSET;
        if (is_string($currentUserParams[self::DB_CHARSET])
            && strpos($currentUserParams[self::DB_CHARSET], '-') !== false
        ) {
            $currentUserParams[self::DB_CHARSET] = str_replace(
                '-',
                '',
                trim(strtoupper($currentUserParams[self::DB_CHARSET]))
            );
        }

        if (isset($currentUserParams[self::DB_COLLATE])) {
            $collate = isset($currentUserParams[self::DB_COLLATE])
                ? $currentUserParams[self::DB_COLLATE]
                : null;
            if (!is_string($collate) && $currentUserParams[self::DB_DRIVER] === 'mysql') {
                $collate = 'utf8_unicode_ci';
            }
            $collate = preg_replace('`(\-|\_)+`', '_', $collate);
            $collate = trim(strtolower($collate));
            $collateArray = explode('_', $collate);
            $charset = reset($collateArray)?: $charset;
        }

        if (!is_string($currentUserParams[self::DB_CHARSET])
            || trim($currentUserParams[self::DB_CHARSET]) === ''
        ) {
            $currentUserParams[self::DB_CHARSET] = $charset;
        }

        return $currentUserParams;
    }
685869
public function parseFuelConfig(array $config)
	{
		$params = array();

		$params['driver'] = $config['type'];

		if ($params['driver'] === 'pdo')
		{
			list($type, $dsn) = explode(':', $config['connection']['dsn'], 2);

			$params['driver'] .= '_' . $type;

			$dsn = explode(';', $dsn);

			foreach ($dsn as $d)
			{
				list($k, $v) = explode('=', $d);

				$params[$k] = $v;
			}
		}
		else
		{
			$params['dbname'] = $config['connection']['database'];
			$params['host'] = $config['connection']['hostname'];
			$params['port'] = Arr::get($config, 'connection.port');
		}

		$params['user'] = Arr::get($config, 'connection.username');
		$params['password'] = Arr::get($config, 'connection.password');
		$params['charset'] = Arr::get($config, 'charset');

		return $params;
	}
1299090
protected function buildParams(array $params)
    {
        $normalizedParameters = array();

        foreach ($params as $parameter) {
            if ($parameter instanceof GeneratorInstance) {
                /* @var $parameter GeneratorInstance */
                $normalizedParameters[] = sprintf('$di->get(%s)', '\'' . $parameter->getName() . '\'');
            } else {
                $normalizedParameters[] = var_export($parameter, true);
            }
        }

        return $normalizedParameters;
    }
1132597
protected function normalizeOptions(array $options): array
    {
        $options = array_replace($this->getDefaultOptions(), $options);

        $options['cacheDir'] = PathResolver::realpath($options['cacheDir']);

        if (!$options['cacheDir']) {
            throw new \RuntimeException('You need to provide valid cache directory for Go! AOP framework.');
        }

        $options['excludePaths'][] = $options['cacheDir'];
        $options['excludePaths'][] = __DIR__ . '/../';
        $options['appDir']         = PathResolver::realpath($options['appDir']);
        $options['cacheFileMode']  = (int) $options['cacheFileMode'];
        $options['includePaths']   = PathResolver::realpath($options['includePaths']);
        $options['excludePaths']   = PathResolver::realpath($options['excludePaths']);

        return $options;
    }
401729
protected function getRequestConfig(array $config) : array
    {
        if (!empty($this->defaultRequestOptions)) {
            $config = array_replace_recursive($this->defaultRequestOptions, $config);
        }

        return $config;
    }
806472
protected function normalizeParams(array $params) {
		$processed = [];
		
		foreach ($params as $param => $value) {
			$processed[sprintf($this->paramsPattern, $param)] = $value;
		}
		
		return $processed;
	}
1165568
public function normalizeParams(array $params): array
    {
        foreach ($params as $key => $value) {
            if (false === \is_string($value) && false === \is_resource($value)) {
                $params[$key] = json_encode($value);
            }
        }

        return $params;
    }
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;
    }
809673
protected function formatS3Config(array $config)
    {
        $config += ['version' => 'latest'];
        if ($config['key'] && $config['secret']) {
            $config['credentials'] = ArrayHelper::only($config, ['key', 'secret']);
        }
        return $config;
    }
266426
public function loadConfigValues(array $configValues) : array
    {
        if (!isset($configValues['master_language'])) {
            throw new Exception('Your configuration file must define a master_language');
        }

        if (
            !isset($configValues['languages']) ||
            !is_array($configValues['languages'])
        ) {
            throw new Exception('Your configuration file must define a set languages for translations');
        }

        if (
            !isset($configValues['paths']) ||
            !is_array($configValues['paths'])
        ) {
            throw new Exception('Your configuration file must define a set of paths where to find translations');
        }

        return $configValues;
    }
1259981
private function normalizeConfig(array $config)
    {
        // Backwards compatibility with old config format: `toolstack` is
        // changed to application `type` and `build`.`flavor`.
        if (isset($config['toolstack'])) {
            if (!strpos($config['toolstack'], ':')) {
                throw new InvalidConfigException("Invalid value for 'toolstack'");
            }
            list($config['type'], $config['build']['flavor']) = explode(':', $config['toolstack'], 2);
        }

        // The `web` section has changed to `web`.`locations`.
        if (isset($config['web']['document_root']) && empty($config['web']['locations'])) {
            $oldConfig = $config['web'] + $this->getOldWebDefaults();

            $location = &$config['web']['locations']['/'];

            $location['root'] = $oldConfig['document_root'];
            $location['expires'] = $oldConfig['expires'];
            $location['passthru'] = $oldConfig['passthru'];
            $location['allow'] = true;

            foreach ($oldConfig['whitelist'] as $pattern) {
                $location['allow'] = false;
                $location['rules'][$pattern]['allow'] = true;
            }

            foreach ($oldConfig['blacklist'] as $pattern) {
                $location['rules'][$pattern]['allow'] = false;
            }
        }

        return $config;
    }
799971
protected function normalizeArguments(array $arguments)
    {
        if (count($arguments) === 2) {
            return [$arguments[0] => $arguments[1]];
        }

        if ($arguments[0] instanceof Arrayable) {
            return $arguments[0]->toArray();
        }

        if (! is_array($arguments[0])) {
            $arguments[0] = [$arguments[0]];
        }

        return $arguments[0];
    }
363979
private static function normalizeRules($fields): array
    {
        $result = [];

        foreach ((array)$fields as $k => $v) {
            if (is_numeric($k)) {
                $result[$v] = true;
            } else {
                $result[$k] = $v;
            }
        }

        return $result;
    }
1137951
public function normalizeArgs(array $args): array
    {
        $normalized = [];

        foreach ($args as $arg) {
            if (\preg_match('/^\-\w{2,}/', $arg)) {
                $splitArg   = \implode(' -', \str_split(\ltrim($arg, '-')));
                $normalized = \array_merge($normalized, \explode(' ', '-' . $splitArg));
            } elseif (\preg_match('/^\-\-\w{2,}\=/', $arg)) {
                $normalized = \array_merge($normalized, explode('=', $arg));
            } else {
                $normalized[] = $arg;
            }
        }

        return $normalized;
    }
1291353
public function mergeConfig($resources)
    {
        $configs = array();
        foreach (is_array($resources) ? $resources : func_get_args() as $resource) {
            $configs = ArrayUtils::merge($configs, $this->loadConfig($resource));
        }

        return $configs;
    }
293939
public function setConfig(array $configs = array() )
  {
    foreach($configs as $config_key => $config)
    {
      switch($config_key)
      {
        case 'table-striped':
          $this->table_striped = $config;
        break;
        case 'table-bordered':
          $this->table_bordered = $config;
        break;
        case 'table-hover':
          $this->table_hover = $config;
        break;
        case 'table-condensed':
          $this->table_condensed = $config;
        break;
        case 'table-responsive':
          $this->table_responsive = $config;
        break;
        case 'id':
          $this->id = $config;
          break;
        default:
          throw new \InvalidArgumentException();
        break;
      }
    }
  }
789337
protected function _prepareConnectionParams(array $config)
    {
        $params = [];
        $params['config'] = [];
        foreach ($config as $key => $value) {
            if (\in_array($key, ['bigintConversion', 'curl', 'headers', 'url'])) {
                $params['config'][$key] = $value;
            } else {
                $params[$key] = $value;
            }
        }

        return $params;
    }