Resolves variable placeholders.
string $template A template string:
array $vars Variable names:
array $values Variable values:
string The resolved string
\InvalidArgumentException If there is a variable with no value
public static function resolve($template, array $vars, array $values) {
$map = array();
foreach ($vars as $var) {
if (false === strpos($template, '{' . $var . '}')) {
continue;
}
if (!isset($values[$var])) {
throw new \InvalidArgumentException(sprintf('The path "%s" contains the variable "%s", but was not given any value for it.', $template, $var));
}
$map['{' . $var . '}'] = $values[$var];
}
return strtr($template, $map);
}