Add implode method

Ensure that imploded values are wrapped with the correct prefix
and suffix, and have the correct separators.
This commit is contained in:
Oliver Davies 2018-01-05 00:02:14 +00:00
parent 6ccf830d23
commit f32d4a5139
2 changed files with 10 additions and 2 deletions

View file

@ -63,7 +63,7 @@ class Builder
private function buildProperty($value, $key)
{
if (collect(['from', 'to'])->contains($key)) {
$value = collect($value)->implode('|');
$value = $this->implode($value);
}
return vsprintf("<apps:property name='%s' value='%s'/>", [
@ -71,4 +71,12 @@ class Builder
htmlentities($value),
]);
}
/**
* Implode values with the appropriate prefix, suffix and separator.
*/
private function implode($value, $separator = '|')
{
return sprintf('(%s)', collect($value)->implode($separator));
}
}