seperator als objekt variable umgesetzt
This commit is contained in:
parent
fa7d635ee9
commit
e8bb01844e
|
@ -33,6 +33,12 @@ class StringBuilder {
|
|||
*/
|
||||
protected $varSuffix = "}}";
|
||||
|
||||
/**
|
||||
* Hält den String, welcher zwischen den Teilen in den Gesamt-String eingefügt wird.
|
||||
* @var string
|
||||
*/
|
||||
protected $seperator = "";
|
||||
|
||||
/**
|
||||
* Hält fest ob alle Teile des Strings einmalig (unique) sein sollen.
|
||||
* @var bool
|
||||
|
@ -49,6 +55,24 @@ class StringBuilder {
|
|||
$this->vars = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzte den Seperierungs String, welcher zwischen die Teile eingefügt wird beim zusammensetzen des gesamt-Strings.
|
||||
* @param string $seperator Seperator der Teile im Gesamt-String
|
||||
* @return StringBuilder $this
|
||||
*/
|
||||
public function setSeperator(string $seperator) : StringBuilder {
|
||||
$this->seperator = $seperator;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abfrage des Seperators, welcher zwischen Teile im Gesamt-String eingefügt wird.
|
||||
* @return string Seperators, welcher zwischen Teile im Gesamt-String eingefügt wird
|
||||
*/
|
||||
public function getSeperator() : string {
|
||||
return $this->seperator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft ob ein Teil vorhanden ist oder eine Zeichenkette insgesamt (variablen nicht ersetzt).
|
||||
* @param string $searchString Wonach soll gesucht werden?
|
||||
|
@ -213,8 +237,8 @@ class StringBuilder {
|
|||
* @param string $seperator
|
||||
* @return string
|
||||
*/
|
||||
public function join(string $seperator='') : string {
|
||||
return implode($seperator, $this->parts);
|
||||
public function join() : string {
|
||||
return implode($this->getSeperator(), $this->parts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -222,8 +246,8 @@ class StringBuilder {
|
|||
* @param string $seperator
|
||||
* @return string
|
||||
*/
|
||||
public function joinUnique(string $seperator='') : string {
|
||||
return implode($seperator, array_unique($this->parts));
|
||||
public function joinUnique() : string {
|
||||
return implode($this->getSeperator(), array_unique($this->parts));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue