From b04bbd604c29955e23b56c71f47fd6d7e9809e91 Mon Sep 17 00:00:00 2001 From: Ashley Allen Date: Tue, 20 Apr 2021 22:52:08 +0100 Subject: [PATCH 1/2] Added sole() to Enumerable contract. --- src/Illuminate/Collections/Enumerable.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Illuminate/Collections/Enumerable.php b/src/Illuminate/Collections/Enumerable.php index 4bda35476905..c2a9f7ec8785 100644 --- a/src/Illuminate/Collections/Enumerable.php +++ b/src/Illuminate/Collections/Enumerable.php @@ -808,6 +808,20 @@ public function slice($offset, $length = null); */ public function split($numberOfGroups); + /** + * Get the first item in the collection, but only if exactly + * 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. * From 3dfd8872322485f9f2aca27cc49b6f12e8d5fb9e Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Apr 2021 08:12:50 -0500 Subject: [PATCH 2/2] Update Enumerable.php --- src/Illuminate/Collections/Enumerable.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Illuminate/Collections/Enumerable.php b/src/Illuminate/Collections/Enumerable.php index c2a9f7ec8785..29b123d53525 100644 --- a/src/Illuminate/Collections/Enumerable.php +++ b/src/Illuminate/Collections/Enumerable.php @@ -809,8 +809,7 @@ public function slice($offset, $length = null); public function split($numberOfGroups); /** - * Get the first item in the collection, but only if exactly - * item exists. Otherwise, throw an exception. + * Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception. * * @param mixed $key * @param mixed $operator