Substitute defined variables, if any found and return the new configuration object

@param Config $config
@param string $prefix
@param string $suffix
@return Config
779572
protected function substituteVars(Config $config, $prefix = '{', $suffix = '}')
    {
        $arrayConfig = $config->toArray();
        if (isset($arrayConfig['variables'])) {
            $vars = array_map(
                function ($x) use ($prefix, $suffix) {
                    return $prefix . $x . $suffix;
                },
                array_keys($arrayConfig['variables'])
            );
            $vals = array_values($arrayConfig['variables']);
            $tokens = array_combine($vars, $vals);
            $processor = new Token();
            $processor->setTokens($tokens);
            $processor->process($config);
            // Remove variables node
            unset($config->variables);
        }
        return $config;
    }
1114058
public static function fromConfig(Config $config)
    {
        $message = sprintf(
            'Could not instantiate OptionRepository from Config with starting key "%1$s".',
            empty($config->getKeys())
                ? '<none>'
                : $config->getKeys()[0]
        );

        return new static($message);
    }
60792
protected function setConfig(array $config = array())
    {
        $this->config = $config;

        if (isset($config['prefix'])) {
            $this->prefix = $config['prefix'];
        }

        if (isset($config['host'])) {
            $this->host = $config['host'];
        }

        if (isset($config['port'])) {
            $this->port = $config['port'];
        }

        return $this;
    }
651339
public function setConfig(array $config, $merge = false)
    {
        $this->config = ($merge)
            ? array_merge($this->config, $config)
            : $config;

        $this->validateConfig();

        return $this;
    }
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;
    }
451839
public function loadConfigurations(IConfiguration $config, $configFolder, $usePrefix = false) {
        $diretory = new \DirectoryIterator($configFolder);
        foreach($diretory as $fileinfo) {
            if($fileinfo->isDot() ||
                    !$fileinfo->isFile() ||
                    !$fileinfo->isReadable() ||
                    substr($fileinfo->getFilename(), -strlen($this->extension), strlen($this->extension)) != $this->extension) {
                continue;
            }

            $prefix = "";
            if($usePrefix) {
                $prefix = substr($fileinfo->getFilename(), 0, -strlen($this->extension));
            }
            $config->loadFile($fileinfo->getPathname(), $prefix);
        }

        return $config;
    }
369221
protected function addSuffix($suffix, $string)
    {
        if (substr($string, -strlen($suffix)) !== (string) $suffix) {
            $string .= $suffix;
        }

        return $string;
    }
366605
public String createNewVariableOnSolver(final String prefix) {
        final int index = this.name2idx.size() + 1;
        final String varName = prefix + "_" + index;
        this.name2idx.put(varName, index);
        this.idx2name.put(index, varName);
        return varName;
    }
1328743
public static function alias(&$config, $key, $alias){
		if(!isset($config[$alias]))
			return;
		$tmp = & $config;
		foreach(explode('.', $key) as $key){
			$tmp = & $tmp[$key];
		}
		if(!isset($tmp))
			$tmp = $config[$alias];
	}
856606
public function load(Config $config)
    {
        if (null === $config) {
            $config = new Config();
        }

        $this->loadExtensions($config);

        return $this
            ->applyCommands($config)
            ->applyHooks($config)
        ;
    }
12443
protected function _load($config, $path, $prefix = '')
    {
        if (file_exists($path)) {
            $config->load($path, $prefix);
        }

        $localConfig = preg_replace('/(.*)\.ini$/', '$1.local.ini', $path);
        if (file_exists($localConfig)) {
            $config->load($localConfig, $prefix);
        }
    }
104523
def config(self, name, suffix):
        ""
        var = '%s_%s' % (name, suffix)
        var = var.upper().replace('-', '_')
        if var in self._config:
            return self._config[var]
        return os.environ[var]
1176234
public void addAll(Configuration other, String prefix) {
		final StringBuilder bld = new StringBuilder();
		bld.append(prefix);
		final int pl = bld.length();

		synchronized (this.confData) {
			synchronized (other.confData) {
				for (Map.Entry<String, Object> entry : other.confData.entrySet()) {
					bld.setLength(pl);
					bld.append(entry.getKey());
					this.confData.put(bld.toString(), entry.getValue());
				}
			}
		}
	}
1208823
protected function setPrefix($prefix) {
        if ($this->configured) throw new IllegalStateException('Configuration is frozen');
        if ($len=strlen($prefix)) {
            if ($prefix[     0] == '/') throw new StrutsConfigException('Non-root module prefixes must not start with a slash "/" character, found: "'.$prefix.'"');
            if ($prefix[$len-1] != '/') throw new StrutsConfigException('Non-root module prefixes must end with a slash "/" character, found: "'.$prefix.'"');
        }
        $this->prefix = $prefix;
    }
316893
public function toAttr($prefix='', $suffix='') {
        $attrs = array();
        if ($this->width !== FALSE) {
            $attrs[] = 'width="'.addslashes($this->width).'"';
        }
        if ($this->height !== FALSE) {
            $attrs[] = 'height="'.addslashes($this->height).'"';
        }
        return $prefix.implode(' ', $attrs).$suffix;
    }
305455
public function initConfig($config)
    {  
        if (is_string($config)) {
            if (file_exists(($configFile = $config)) ||
                file_exists(($configFile = dirname(dirname(__FILE__)).self::DS.$config))
            ) {
                $config = $this->loadConfig($configFile);
            }
        } elseif (!is_array($config) && !is_object($config)) {
            throw new \Exception("Invalid configuration.", 1);
        }

        $this->mergeConfig($config);

        $this->doCallback('configurationInitiated', array($this->_configuration, $this));

        return $this;
    }
158254
public function guessConfigPathFrom($class, $suffix = '')
    {
        $classFolder = strtolower(class_basename($class));
        $classFile = realpath(dirname(File::fromClass($class)));
        return $classFile ? $classFile . '/' . $classFolder . $suffix : null;
    }