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 content()
 {
     $stubContent = file_get_contents($this->stubFilePath());
     $strSubstitutor = new StrSubstitutor(array('action' => $this->actionGenerator->getActionName()));
     return $strSubstitutor->replace($stubContent);
 }
 public function content()
 {
     $stubContent = file_get_contents($this->stubFilePath());
     $strSubstitutor = new StrSubstitutor(array('namespace' => $this->generator->getClassNamespace(), 'class' => $this->generator->getClassName()));
     return $strSubstitutor->replace($stubContent);
 }
Пример #3
0
 /**
  * @test
  */
 public function shouldReplaceWithSpaceInPlaceholderName()
 {
     //given
     $strSubstitutor = new StrSubstitutor(array('SOME PLACEHOLDER' => 'new value'));
     //when
     $substituted = $strSubstitutor->replace('Value: {{SOME PLACEHOLDER}}');
     //then
     $this->assertEquals('Value: new value', $substituted);
 }