Ouzo\Utilities\StrSubstitutor::replace PHP Метод

replace() публичный Метод

Example: $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 replace ( string $string ) : mixed
$string string
Результат mixed
    public function replace($string)
    {
        return preg_replace_callback('/\\{\\{(.+?)}}/u', array($this, '_replace_vars'), $string);
    }

Usage Example

 public function content()
 {
     $stubContent = file_get_contents($this->stubFilePath());
     $strSubstitutor = new StrSubstitutor(array('action' => $this->actionGenerator->getActionName()));
     return $strSubstitutor->replace($stubContent);
 }
All Usage Examples Of Ouzo\Utilities\StrSubstitutor::replace