Skip to content

Commit

Permalink
[9.x] Add sole() to Enumerable contract. (#37066)
Browse files Browse the repository at this point in the history
* Added sole() to Enumerable contract.

* Update Enumerable.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
ash-jc-allen and taylorotwell committed Apr 21, 2021
1 parent c0a3169 commit e769e3d
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit e769e3d

Please sign in to comment.