8000 [9.x] Add sole() to Enumerable contract. (#37066) · laravel/framework@e769e3d · GitHub
[go: up one dir, main page]

Skip to content

Commit e769e3d

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 c0a3169 commit e769e3d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Illuminate/Collections/Enumerable.php

Lines changed: 13 additions & 0 deletions
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)
0