Parse the config and replace curl.* configurators into the constant based values so it can be used elsewhere

@param array|Collection $config The configuration we want to parse

@return array
763097
public static function parseCurlConfig($config)
    {
        $curlOptions = array();
        foreach ($config as $key => $value) {
            if (is_string($key) && defined($key)) {
                // Convert constants represented as string to constant int values
                $key = constant($key);
            }
            if (is_string($value) && defined($value)) {
                $value = constant($value);
            }
            $curlOptions[$key] = $value;
        }

        return $curlOptions;
    }
143241
public static function convertRetry(array $config)
    {
        // TODO: add deprecation
        if (isset($config['curlCodes'])) {
            $config['curl'] = [];
            $config['curl']['codes'] = $config['curlCodes'];
            unset($config['curlCodes']);
        }

        if (isset($config['headerName']) || isset($config['httpCodes'])) {
            $config['http'] = [];

            if (isset($config['headerName'])) {
                $config['http']['retryHeader'] = $config['headerName'];
                unset($config['headerName']);
            }
            if (isset($config['httpCodes'])) {
                $config['http']['codes'] = $config['httpCodes'];
                unset($config['httpCodes']);
            }
        }

        return $config;
    }
292616
public function getMongoDb($config)
	{
		if( class_exists( 'MongoClient' ) )
		{
			$class = 'MongoClient';
		}
		else
		{
			$class = 'Mongo';
			debug_enforce(
				class_exists( $class ),
				"No 'Mongo' class available. Make sure you've installed php mongo extension correctly."
			);
		}

		$confOptions = array();

		if (!empty($config["mongo_username"])) {
			$confOptions["username"] = $config["mongo_username"];
		}

		if (!empty($config["mongo_password"])) {
			$confOptions["password"] = $config["mongo_password"];
		}

		/** @var $_conn Mongo */
		$_conn = new $class(
			'mongodb://'.$config['mongo_host'],
			$confOptions
		);
		$dbMongo = $_conn->selectDB($config["db_name"]);

		$dbMongo->listCollections();
		return $dbMongo;
	}
456427
public static function buildConfig($config = array())
    {
        $default = static::getDefaultParameters();
        $required = static::getRequiredParameters();
        $config = Collection::fromConfig($config, $default, $required);

        $standardHeaders = array(
            'Accept-Charset' => 'utf-8',
            'Accept'         => 'application/json',
        );

        $requestOptions = array(
            'headers' => $standardHeaders,
        );

        $config->add('request.options', $requestOptions);

        return $config;
    }
959287
public function getTokens(array $config = [])
    {
        $query = $this->hasMany(
            Token::class,
            ['providerId' => 'id']
        );

        if (!empty($config)) {
            QueryHelper::configure(
                $query,
                $config
            );
        }

        return $query;
    }
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;
    }
395944
public static function invoke(
        array $fieldsConfig
    ): array {
        $fieldsConfigByName = [];
        foreach ($fieldsConfig as $fieldConfig) {
            $name = Property::getRequired(
                $fieldConfig,
                FieldConfig::NAME
            );
            $fieldsConfigByName[$name] = $fieldConfig;
        }

        return $fieldsConfigByName;
    }
433871
protected function processConfig(array $config)
    {
        return [
            'model'      => $config['model'],
            'table'      => $this->getModelTable($config['model']),
            'field'      => snake_case($config['field']),
            'key'        => snake_case($this->key($config['key'])),
            'foreignKey' => snake_case($this->key($config['foreignKey'])),
        ];
    }
357244
public function parseString($config)
    {
        try {
            $data = YamlParser::parse($config, YamlParser::PARSE_CONSTANT);
        } catch (Exception $exception) {
            throw new ParseException(
                [
                    'message'   => 'Error parsing YAML string',
                    'exception' => $exception,
                ]
            );
        }

        return (array)$this->parse($data);
    }
546247
public static function config($config = []) {
		if (!$config) {
			return ['classes' => static::$_classes, 'unicode' => static::$_unicode];
		}
		if (isset($config['classes'])) {
			static::$_classes = $config['classes'] + static::$_classes;
		}
		if (isset($config['unicode'])) {
			static::$_unicode = $config['unicode'];
		}
	}
407487
public function transform(string $config = ''): array
    {
        $parsed = [];

        if (!\extension_loaded('php_yaml')) {
            return $parsed;
        }
        if (!empty($config)) {
            $parsed = \yaml_parse($config);
            $parsed = $parsed !== null ? $parsed : [];
        }

        return $parsed;
    }
89662
protected function isParsedConfigValid(array $config)
    {
        $inConfig = count(array_intersect_key(array_flip($this->required), $config));

        return $inConfig === count($this->required);
    }
1050401
public static function unserialize(array $config)
    {
        $configuration = new static;

        if (false !== ($clientConfiguration = unserialize($config['watched_files']))) {
            $configuration->set($clientConfiguration);
        }

        return $configuration;
    }
516644
public function transform(string $config = ''): array
    {
        $config = \preg_replace('/^(<\?xml\ version="[^"]+"\ encoding="[^"]+"\?>)?(\n)?/i', '', $config);
        $parsed = [];
        if (!empty($config)) {
            $node = new \SimpleXMLElement($config);
            if ($node->count() > 0) {
                $parsed = $this->processNode($node->children());
            }
        }
        return $parsed;
    }
120354
protected function normalizeConnectionConfig(array $config)
    {
        $adapter = $this->createConfigurationAdapter($config['driver']);

        $configuration = new ConnectionConfiguration($adapter);

        return $configuration->map($config);
    }
1335136
private function parseConfig(array $config = [])
    {
        $this->apiConfig = $this->extractGuzzleConfig($config);

        if (ConfigUtils::configurationExists($this->apiConfig, 'apiDescription')) {
            $this->apiDescription = $this->apiConfig['apiDescription'];
        }
        if (ConfigUtils::configurationExists($this->apiConfig, 'authType')) {
            $this->authType = $this->apiConfig['authType'];
        }
        if (ConfigUtils::configurationExists($this->apiConfig, 'debug')) {
            $this->debugMode = $this->apiConfig['debug'];
            if (ConfigUtils::configurationExists($this->apiConfig, 'debugLogger')) {
                $this->debugLogger = $this->apiConfig['debugLogger'];
            }
        }
    }
1258349
private function convertToArray(array $config)
    {
        foreach ($config as $key => &$value) {
            if (is_array($value)) {
                $value = $this->convertToArray($value);

                if (!$value) {
                    unset($config[$key]);
                }
            } elseif ($value instanceof IConfigValue) {
                if ($value->has(IConfigValue::KEY_LOCAL)) {
                    $value = $value->get(IConfigValue::KEY_LOCAL);
                } else {
                    unset($config[$key]);
                }
            } elseif ($value instanceof IConfigSource) {
                unset($config[$key]);
            } else {
                throw new UnexpectedValueException($this->translate(
                    'Config source is corrupted.'
                ));
            }
        }

        return $config;
    }