src/ParameterBag.php
public function resolveString($value, array $resolving = array())
    {
        $parts = explode('%', $value);
        $keyOnly = (bool) preg_match('/^%([^%\s]+)%$/', $value);
        $return = $parts[0];

        for ($i = 1, $last = count($parts) - 1; $i <= $last; ++$i) {
            $part = $parts[$i];
            $key = strtolower($part);

            if (0 === $i % 2) {
                $return .= $part;
            } elseif ($last === $i) {
                $return .= '%' . $part;
            } elseif (empty($part) || preg_match('/ /', $part)) {
                $return .= '%' . $part . '%';
            } elseif (isset($resolving[$key])) {
                throw new ParameterCircularReferenceException($key, array_keys($resolving));
            } else {
                $resolved = $this->get($key);

                if (true === $keyOnly) {
                    return $this->resolved ? $resolved : $this->resolveValue($resolved, array_merge($resolving, array($key => true)));
                } elseif (!is_string($resolved) && !is_numeric($resolved)) {
                    throw new RuntimeException('Resolved value is not a string or numbers');
                }

                $resolved = (string) $resolved;
                $return .= $this->resolved ? $resolved : $this->resolveValue($resolved, array_merge($resolving, array($key => true)));
            }
        }

        return $return;
    }
public function resolveString($value, array $resolving = array())
    {
        $parts = explode('%', $value);
        $keyOnly = (bool) preg_match('/^%([^%\s]+)%$/', $value);
        $return = $parts[0];

        for ($i = 1, $last = count($parts) - 1; $i <= $last; ++$i) {
            $part = $parts[$i];
            $key = strtolower($part);

            if (0 === $i % 2) {
                $return .= $part;
            } elseif ($last === $i) {
                $return .= '%' . $part;
            } elseif (empty($part) || preg_match('/ /', $part)) {
                $return .= '%' . $part . '%';
            } elseif (isset($resolving[$key])) {
                throw new ParameterCircularReferenceException($key, array_keys($resolving));
            } else {
                $resolved = $this->get($key);

                if (true === $keyOnly) {
                    return $this->resolved ? $resolved : $this->resolveValue($resolved, array_merge($resolving, array($key => true)));
                } elseif (!is_string($resolved) && !is_numeric($resolved)) {
                    throw new RuntimeException('Resolved value is not a string or numbers');
                }

                $resolved = (string) $resolved;
                $return .= $this->resolved ? $resolved : $this->resolveValue($resolved, array_merge($resolving, array($key => true)));
            }
        }

        return $return;
    }
Resolves parameters inside a string

@param string $value     The string to resolve
@param array  $resolving An array of keys that are being resolved (used internally to detect circular references)

@return string The resolved string

@throws ParameterCircularReferenceException
@throws RuntimeException