methode zum unique teile rendern hinzugefügt

This commit is contained in:
Marcel Naeve 2024-04-20 17:35:25 +02:00
parent e8bb01844e
commit 9dae115ad4
Signed by: manae
GPG Key ID: 3BB68BF9EA669981
1 changed files with 15 additions and 0 deletions

View File

@ -263,4 +263,19 @@ class StringBuilder {
} }
return $tpl; return $tpl;
} }
/**
* Alle Teile zu einem String zusammenfügen, wärend doppelt vorkommende Teile nicht erneut vorkommen und dann variablen im gesamt String ersetzen.
* @return string Gesamt-String mit Variablen ersetzt.
*/
public function renderUnique() : string {
$tpl = $this->joinUnique();
foreach($this->vars as $key => $value) {
if(is_numeric($value) or is_string($value)) {
$tpl = preg_replace("/".$this->varPrefix."\s*".$key."\s*".$this->varSuffix."/", $value, $tpl);
}
}
return $tpl;
}
} }