Skip to content

Commit

Permalink
Add unshift method to Collection (#51344)
Browse files Browse the repository at this point in the history
  • Loading branch information
timkelty committed May 8, 2024
1 parent 3859367 commit 48f7309
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,19 @@ public function push(...$values)
return $this;
}

/**
* Prepend one or more items to the beginning of the collection.
*
* @param TValue ...$values
* @return $this
*/
public function unshift(...$values)
{
array_unshift($this->items, ...$values);

return $this;
}

/**
* Push all of the given items onto the collection.
*
Expand Down

0 comments on commit 48f7309

Please sign in to comment.