It interpolates the given string replacing its placeholders with the
values defined in the given variables array.

@param string $string
@param array  $variables

@return string
541842
private function processStringPlaceholders($string, array $variables)
    {
        foreach ($variables as $key => $value) {
            if (!is_string($value) && !is_numeric($value) && !is_bool($value)) {
                continue;
            }

            $string = str_replace('{'.$key.'}', $value, (string) $string);
        }

        return $string;
    }
430590
private function transformRouteVariables(string $route, array $variables) : string
    {
        list($valueToReplace, , $parametersVariables) = array_pad(
            $variables,
            3,
            null
        );

        if (isset($parametersVariables)) {
            return str_replace(
                $valueToReplace,
                '('.reset($parametersVariables).')',
                $route
            );
        }

        return str_replace($valueToReplace, '([^/]+)', $route);
    }
1064809
public function interpolate($string, $style = '')
    {
        return preg_replace_callback("/{(([[:alnum:]]|_|\.|-)+)?}/", function ($match) use ($style) {
            $key = $match[1];

            // Create local method call.
            $method = 'get' . studly_case($key);

            // Check for a custom interpolator value.
            if (method_exists($this, $method)) {
                return $this->$method($style);
            }

            // Check for an interpolator override
            if ($override = $this->manager->config("interpolate.{$key}")) {
                return $override;
            }

            return $this->getAttribute($key);
        }, $string);
    }
1102472
protected function searchAndReplaceVariables($string)
    {
        return str_replace(
            ['{$major}', '{$minor}', '{$patch}', '{$repository}', '{$build}'],
            [
                $this->getVersion('major'),
                $this->getVersion('minor'),
                $this->getVersion('patch'),
                $this->git->getGitRepository(),
                $this->getBuild(),
            ],
            $string
        );
    }
185631
public static function convertVariableToString($variable) {
		$string = '';
		if (is_array($variable)) {
			$string = self::viewArray($variable);
		} elseif (is_object($variable)) {
			$string = '<strong>|Object:<pre>';
			$string .= print_r($variable, TRUE);
			$string .= '</pre>|</strong>';
		} elseif ((string) $variable !== '') {
			$string = '<strong>|' . htmlspecialchars((string) $variable) . '|</strong>';
		} else {
			$string = '<strong>| debug |</strong>';
		}

		return $string;
	}
825054
public static function get($string)
    {
        $vars = func_get_args();

        if (array_key_exists($string, self::$strings)) {
            $vars[0] = self::$strings[$string];
            return call_user_func_array('sprintf', $vars);
        }

        return '%%MISSING STRING: ' . $string . '%%';
    }
574606
public static function variable($string) {
        $string = preg_replace('/[^_a-z0-9]+/i', '', $string);

        if (is_numeric(mb_substr($string, 0, 1))) {
            $string = '_' . $string;
        }

        return $string;
    }
366696
public function tostr(...$strings)
    {
        $new_string = '';
        foreach ($strings as $temp) {
            switch (gettype($temp)) {
                case "array":
                    $it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($temp));
                    foreach($it as $v) {
                        $temp_str .= ' ' . $this->tostr($v);
                    }
                    break;
                default:
                    $temp_str = (string)$temp;
                    break;
            }
            $new_string .= $temp_str;
        }
        return trim($new_string);
    }
1041684
public function translate($string, Array $vars = array())
    {
        // Use custom translator
        if ($this->translator) {
            return $this->translator($this->getString($string), $vars);
        }

        return $this->compileString($this->getString($string), $vars);
    }
198607
public static function format(string $string, array $values, $options = null) : string
    {
        if ($options instanceof Settings) {
            $settings = $options;
        } elseif (is_array($options)) {
            $settings = new Settings($options);
        } else {
            $settings = new Settings();
        }

        $settings->hasRequiredSettings();

        return self::parseString($string, $values, $settings);
    }
437149
public function render($string, array $vars = array())
    {
        $fileName = uniqid(time(), false);
        $this->generateDirectoryStructure(storage_path(), [ 'caffeinated/stubs' ]);
        $path = storage_path("caffeinated/stubs/{$fileName}");
        $this->files->put($path, $this->compiler->compileString($string));

        if (is_array($vars) && ! empty($vars)) {
            extract($vars);
        }

        ob_start();
        include($path);
        $var = ob_get_contents();
        ob_end_clean();

        $this->files->delete($path);

        return $var;
    }
658707
public function interpolate($string, array $params, $level)
    {
        foreach ($params as $placeholder => $value) {
            $params['{'.(string) $placeholder.'}'] = (string) $value;
            unset($params[$placeholder]);
        }
        $message = strtr($string, $params);
        $this->writer($level, $message);
        $this->store([
            'message' => $message,
            'level'   => $level,
        ]);
    }
1088312
public static function insert($string, $data)
    {
        foreach ($data as $key => $value):
            $regex = '%(:' . $key . ')%';
            $string = preg_replace($regex, $value, $string);
        endforeach;

        return $string;
    }
248678
protected function replaceVariables($string)
    {
        do {
            $original = $string;

            $string = $this->searchAndReplaceVariables($string);
        } while ($original !== $string);

        return $string;
    }
785743
public String interpolate() {
        getValues();
        if (definition == null) {
            return "";
        }

        int variableStart = definition.indexOf("{");
        if (variableStart < 0) {
            return definition;
        }

        int index = 0;
        int variableEnd = 0;
        StringBuilder sb = new StringBuilder();
        while (variableStart >= 0) {
            sb.append(definition.substring(variableEnd,
                                           variableStart));
            variableEnd = getIndexForEndOfVariable(definition,
                                                   variableStart) + 1;
            variableStart = definition.indexOf("{",
                                               variableEnd);
            sb.append(values.get(index++).getValue());
        }
        if (variableEnd < definition.length()) {
            sb.append(definition.substring(variableEnd));
        }
        return sb.toString();
    }
489840
public function constructJavaScript($variables)
    {
        return $this->constructNamespace() . collect($variables)->map(function ($value, $name) {
            return $this->initializeVariable($name, $value);
        })->implode('');
    }
109664
public function setValue($string)
    {
        if (! is_array($string)) {
            $string = explode(",", $string);
        }

        $extras = ['noodp', 'noarchive', 'nosnippet',
            'noimageindex', 'noydir', 'nocache'];

        $indexes = ['index', 'noindex'];

        $follows = ['follow', 'nofollow'];

        foreach ($string as $key => $value) {
            $key = trim(strtolower($key));
            $value = trim(strtolower($value));

            if ($key == 'index' || in_array($value, $indexes)) {
                $this->index = $value;
            } elseif ($key == 'follow' || in_array($value, $follows)) {
                $this->follow = $value;
            } elseif (in_array($value, $extras)) {
                $this->extra[] = $value;
            }
        }
        return $this;
    }