Skip to content

Commit ad3a118

Browse files
[9.x] Add sole() to Enumerable contract. (#37066)
* Added sole() to Enumerable contract. * Update Enumerable.php Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 3adf132 commit ad3a118

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Enumerable.php

+13
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,19 @@ public function slice($offset, $length = null);
808808
*/
809809
public function split($numberOfGroups);
810810

811+
/**
812+
* Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception.
813+
*
814+
* @param mixed $key
815+
* @param mixed $operator
816+
* @param mixed $value
817+
* @return mixed
818+
*
819+
* @throws \Illuminate\Collections\ItemNotFoundException
820+
* @throws \Illuminate\Collections\MultipleItemsFoundException
821+
*/
822+
public function sole($key = null, $operator = null, $value = null);
823+
811824
/**
812825
* Chunk the collection into chunks of the given size.
813826
*

0 commit comments

Comments
 (0)