Transforms array in form [1,2 => [3]] to [1=>[], 2=>[3=>[]]].

@param array $config

@return array
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;
    }
1081956
public static function createFromConfig(array $config)
    {
        $fields = [];
        foreach ($config as $name => $field) {
            $fields[$name] = Fields::create($name, $field);
        }
        return new static($fields);
    }
379976
protected function convertValueTypes(array $config)
	{
		foreach ($config as $k => $v)
		{
			if (is_array($v))
			{
				$config[$k] = $this->convertValueTypes($v);
			}
			else
			{
				$config[$k] = $this->castConfigValue($k, $v);
			}
		}

		return $config;
	}
860298
protected function buildHandlers(array $config):array
    {
        $handlers = [];
        foreach ($config as $handler) {
            $level = constant('\Mostofreddy\Loggy\Logger::'. strtoupper($handler['level']));
            $handlerObj = '\Mostofreddy\Loggy\Handler\\'.ucfirst($handler['handler']);
            $handlers[] = (new $handlerObj($level))->config($handler);
        }
        return $handlers;
    }
2120
protected function convertToExcel(array $data, array $config): Collection
    {
        $uses = $config['uses'] ?? 'data';
        $content = $data[$uses] ?? [];

        if ($content instanceof Arrayable) {
            $content = $content->toArray();
        }

        return Collection::make(\array_map([$this, 'transformToArray'], $content));
    }
1202924
public function addFieldsFromConfig(array $config)
    {
        $i = 1;
        foreach ($config as $name => $field) {
            if (is_numeric($name) && !isset($field[$name]['type'])) {
                $fields = [];
                foreach ($field as $n => $f) {
                    $fields[$n] = Fields::create($n, $f);
                }
                if ($i > 1) {
                    $this->fieldsets[$this->current]->createGroup();
                }
                $this->fieldsets[$this->current]->addFields($fields);
                $i++;
            } else {
                $this->addField(Fields::create($name, $field));
            }
        }
        return $this;
    }
494192
public function transformMagicals(array $config)
    {
        if (isset($config['magicals'])) {
            foreach ($config['magicals'] as $magical) {
                if (isset($config['services'][$magical])) {
                    continue;
                }
                if (! isset($config['factories'][$magical])) {
                    $factory = $magical . 'Factory';
                    if (class_exists($factory)) {
                        $config['factories'][$magical] = $factory;
                        continue;
                    }
                    if (! isset($config['invokables'][$magical]) && class_exists($magical)) {
                        $config['invokables'][$magical] = $magical;
                    }
                }
            }
        }
        return $config;
    }
323981
protected function mergeConfigs(array $configs)
    {
        $mergedConfig = array();
        
        foreach($configs as $config)
        {
            $mergedConfig = array_merge_recursive($mergedConfig, $config);
        }
        
        return  array($mergedConfig);
    }
1234909
protected function buildColumns(array $config)
    {
        $columns = [];

        foreach (isset($config['columns']) ? $config['columns'] : [] as $name => $column) {
            $column = $this->buildColumn(array_merge(['name' => $name], $column), $config);
            $columns[$column->getName()] = $column;
        }

        return $columns;
    }
919832
protected function normalizeConfig(array $config)
    {
        // In Stapler, variants were called 'styles'.
        if ( ! Arr::has($config, 'variants') && Arr::has($config, 'styles')) {
            $config['variants'] = Arr::get($config, 'styles', []);
        }
        Arr::forget($config, 'styles');


        // Simple renames of stapler config keys.
        $renames = [
            'url'            => 'path',
            'keep_old_files' => 'keep-old-files',
            'preserve_files' => 'preserve-files',

            // Note that 'url' conflicts with with Paperclip.
            // In Stapler, 'url' is what is 'path' in Paperclip.
            // To allow for full configuration 'missing_url' is mapped to 'url',
            // even though this option was not present in Stapler.
            'missing_url' => 'url',
        ];

        foreach ($renames as $old => $new) {
            if ( ! Arr::has($config, $old)) {
                continue;
            }

            if ( ! Arr::has($config, $new)) {
                $config[ $new ] = Arr::get($config, $old);
            }
            Arr::forget($config, $old);
        }

        return parent::normalizeConfig($config);
    }
891453
public function transform($config)
    {
        array_walk($config, function(&$value, $key) {
            if (in_array($key, $this->getKeys(), true)) {
                $value = $this->transformValue($value);
            } else {
                if ($this->shouldRecurse($value, $key)) {
                    $value = $this->transform($value);
                }
            }
        });

        return $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;
    }
1293018
public function merge_array( $config ) {
		foreach ( $this->spec as $key => $details ) {
			if ( false !== $details['runtime'] && isset( $config[ $key ] ) ) {
				$value = $config[ $key ];

				if ( 'require' === $key ) {
					$value = \WP_CLI\Utils\expand_globs( $value );
				}

				if ( $details['multiple'] ) {
					self::arrayify( $value );
					$this->config[ $key ] = array_merge( $this->config[ $key ], $value );
				} else {
					$this->config[ $key ] = $value;
				}
			}
		}
	}
1041946
public function config($config)
    {
        if (is_array($config)) {
            $this->config = array_merge($this->config, $config);
        } elseif (isset($this->config[$config])) {
            return $this->config[$config];
        } else {
            return;
        }
    }
1324108
protected function getValues( array $config )
	{
		$values = array(
			'absoluteUri' => false,
		);

		if( isset( $config['absoluteUri'] ) ) {
			$values['absoluteUri'] = (bool) $config['absoluteUri'];
		}

		return $values;
	}
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};
        }
    }
135950
protected function flattenConfig(array $config)
	{
		foreach ($config as $k => $v)
		{
			if (is_array($v) && count($v) === 1)
			{
				$config[$k] = end($v);
			}
		}

		return $config;
	}