An overridable method that allows parsing arbitrary strings into config arrays

@param string $config The contents of a config file (or sometimes the filename itself)
@return array The config array resulting from the parse
966032
protected function parseConfig(string $config): array
    {
        $config = json_decode($config, true);
        if ($config === null) {
            throw new ConfigFileFormatException("Config files should be written in valid JSON");
        }
        return $config;
    }
166839
static public function config($config = array())
    {
        !empty($config) && self::$config = array_merge(self::$config, $config);
        if (!empty(self::$config['cachepath'])) {
            Cache::$cachepath = self::$config['cachepath'];
        }
        if (empty(self::$config['component_verify_ticket'])) {
            self::$config['component_verify_ticket'] = Cache::get('component_verify_ticket');
        }
        if (empty(self::$config['token']) && !empty(self::$config['component_token'])) {
            self::$config['token'] = self::$config['component_token'];
        }
        if (empty(self::$config['appsecret']) && !empty(self::$config['component_appsecret'])) {
            self::$config['appsecret'] = self::$config['component_appsecret'];
        }
        if (empty(self::$config['encodingaeskey']) && !empty(self::$config['component_encodingaeskey'])) {
            self::$config['encodingaeskey'] = self::$config['component_encodingaeskey'];
        }
        return self::$config;
    }
299718
public function generate(Config $config)
    {
        $parts = array();
        if ($config->parent) {
            $parts[] = str_replace(
                array('{id}', '.{_format}'),
                array(sprintf('{%sId}', $this->getPrefix($config->parent)), ''),
                $this->generate($config->parent)
            );
        }
        $parts[] = $this->getPrefix($config);

        $prefix = implode('/', array_filter($parts));
        $pattern = $this->getPattern($config);

        if (isset($pattern[0]) && '/' !== $pattern[0] && '.' !== $pattern[0]) {
            return rtrim($prefix, '/').'/'.$pattern;
        }

        return $prefix.$pattern;
    }
1282443
public static function get($config = []) {
        $key = md5(get_called_class() . serialize($config));
        if (!isset(self::$_instances[$key]))
            self::$_instances[$key] = new static($config);
        return self::$_instances[$key];
    }
574996
protected function convertScrapeConfig(array $config)
	{
		$config['extract'] = $this->convertRegexps($config['extract']);
		$config['match']   = $this->convertRegexps($config['match']);

		return $config;
	}
1358321
protected function parseDescriptorField($config)
    {
        if (is_array($config)) {
            $descriptor = [];
            foreach ($config as $field) {
                if (!empty($this->{$field})) {
                    $descriptor[] = $this->{$field};
                }
            }

            return implode(' ', $descriptor);
        } else {
            return $this->{$config};
        }
    }
320392
protected function normalizeConfig(array $config)
    {
        $final = [];
        foreach ($config as $key => $value) {
            if (is_array($value)) {
                $final[$key] = $this->normalizeConfig($value);
            } else {
                $final[$value] = [];
            }
        }

        return $final;
    }
304417
private function mergeConfigParams(array $config)
    {
        foreach ($config as $name => $value) {
            preg_match('/^extend~(.*)~(.*)$/', $name, $matches);

            if (3 === count($matches)) {
                if (!isset($config[$matches[1]])) {
                    throw new ConfigurationException(sprintf('Unable to find parameter "%s" for extending.', $matches[1]));
                }
                if (!is_array($config[$matches[1]])) {
                    throw new ConfigurationException(
                        sprintf('Unable to extend parameter "%s": only array parameters can be extended.', $matches[1])
                    );
                }

                $config[$matches[2]] = $this->mergeConfigs($config[$matches[1]], $value);

                unset($config[$name]);

                continue;
            }
            if (is_array($value)) {
                $config[$name] = $this->mergeConfigParams($value);
            }
        }

        return $config;
    }
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'])),
        ];
    }
1179842
private function getConfigsForUriTemplates($config)
    {
        $configs = [$config];

        if ($config['additionalBindings']) {
            foreach ($config['additionalBindings'] as $additionalBinding) {
                $configs[] = $additionalBinding + $config;
            }
        }

        return $configs;
    }
388271
private function generateArray(array $config)
    {
        ++$this->indent;

        foreach ($config as $key => $value) {
            if (is_null($value)) {
                if (is_string($key)) {
                    $this->writeLine(sprintf("'%s' => %s,", $key, 'null'));
                } else {
                    $this->writeLine(sprintf('%s,', 'null'));
                }
            } elseif (is_bool($value)) {
                if (is_string($key)) {
                    $this->writeLine(sprintf("'%s' => %s,", $key, $value ? 'true' : 'false'));
                } else {
                    $this->writeLine(sprintf('%s,', $value ? 'true' : 'false'));
                }
            } elseif (is_string($value)) {
                if (is_string($key)) {
                    $this->writeLine(sprintf("'%s' => '%s',", $key, $value));
                } else {
                    $this->writeLine(sprintf("'%s',", $value));
                }
            } elseif (is_array($value)) {
                if (is_string($key)) {
                    $this->writeLine(sprintf("'%s' => [", $key));
                } else {
                    $this->writeLine('[');
                }

                $this->generateArray($value);

                $this->writeLine('],');
            } elseif ($value instanceof ClassName) {
                if (is_string($key)) {
                    $this->writeLine(sprintf("'%s' => %s,", $key, (string) $value));
                } else {
                    $this->writeLine(sprintf('%s,', (string) $value));
                }
            } else {
                if (is_string($key)) {
                    $this->writeLine(sprintf("'%s' => %s,", $key, $value));
                } else {
                    $this->writeLine($value.',');
                }
            }
        }

        --$this->indent;
    }
1008926
public static function deserialize(array $config)
    {
        if (isset($config['class']) && isset($config['config'])) {
            $config = $config['config'];
        }
        $instance = new self();
        $instance->loadConfig($config);
        return $instance;
    }
1157288
private function checkConfigKeys($config)
    {
        $config = array_change_key_case($config, CASE_LOWER);
        $config = $this->trimArray($config);

        foreach ($config as $key => $value) {
            if (array_key_exists($key, $this->config)) {
                $this->config[$key] = $value;
            } else {
                throw new \Exception('Key ' . $key . ' is either not part of the configuration or has incorrect Key name.
                check the config array key names to match your key names of your config array', 1);
            }
        }
    }
1309747
protected function configSplit($name, $config = 'default'): array
    {
        if (strpos($name, ':') !== false) {
            $parts = explode(':', $name, 2);

            return $parts;
        }

        return [$config, $name];
    }
363248
public function createFromArray($config)
    {
        foreach ($config as $property => $value) {
            $this->{$property} = $value;
        }

        return $this;
    }
194327
protected static function parseConfig($config, $default)
    {
        array_walk($default, function ($value, $key) use (&$config) {
            if (empty($config[$key]) || !isset($config[$key])) {
                $config[$key] = $value;
            }
        });

        return $config;
    }
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;
    }