$strSubstitutor = new StrSubstitutor(array('NAME' => 'John', 'SURNAME' => 'Smith'));
$substituted = $strSubstitutor->replace('Hi, {{NAME}} {{SURNAME}}');
Result:
Hi, John Smith
Example:
$strSubstitutor = new StrSubstitutor(array(), 'Unknown');
$substituted = $strSubstitutor->replace('Hi, {{NAME}}');
Result:
Hi, Unknown
public function replace($string)
{
return preg_replace_callback('/\\{\\{(.+?)}}/u', array($this, '_replace_vars'), $string);
}
public function content() { $stubContent = file_get_contents($this->stubFilePath()); $strSubstitutor = new StrSubstitutor(array('action' => $this->actionGenerator->getActionName())); return $strSubstitutor->replace($stubContent); }