Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Add sole() to Enumerable contract #37066

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Illuminate/Collections/Enumerable.php
Expand Up @@ -808,6 +808,19 @@ public function slice($offset, $length = null);
*/
public function split($numberOfGroups);

/**
* Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception.
*
* @param mixed $key
* @param mixed $operator
* @param mixed $value
* @return mixed
*
* @throws \Illuminate\Collections\ItemNotFoundException
* @throws \Illuminate\Collections\MultipleItemsFoundException
*/
public function sole($key = null, $operator = null, $value = null);

/**
* Chunk the collection into chunks of the given size.
*
Expand Down