You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
Add a third parameter to Collection::implode() to works like a last item separator ("and", "or"). It should be like Collection::implode($value, $glue = null, $lastGlue = null).
Behavior
Will works only if $lastGlue is not null, else will works exactly as currently;
Will works only if count($this->items) >= 2;
Will get $this->last() and will implode all items except last;
Will concatenate previous value with the $lastGlue and last item;
Example
$collection = newCollection([ '1', '2' ]);
$collection->implode(', '); // string ("1, 2")$collection->implode(', ', ' and '); // string ("1 and 2")$collection->push('3');
$collection->implode(', '); // string ("1, 2, 3")$collection->implode(', ', ' and '); // string ("1, 2 and 3")
Example Macro
Currently I am working with macros, but I think that it could be done by the framework once that is an easy and very useful feature. That is my current version (it have some IDE annotations).
Add a third parameter to
Collection::implode()
to works like a last item separator ("and", "or"). It should be likeCollection::implode($value, $glue = null, $lastGlue = null)
.Behavior
$lastGlue
is notnull
, else will works exactly as currently;count($this->items) >= 2
;$this->last()
and will implode all items except last;$lastGlue
and last item;Example
Example Macro
Currently I am working with macros, but I think that it could be done by the framework once that is an easy and very useful feature. That is my current version (it have some IDE annotations).
References:
The text was updated successfully, but these errors were encountered: