Skip to content

Commit 8a03a77

Browse files
Merge branch '8.x'
2 parents 6503abc + ecc881c commit 8a03a77

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Collection.php

+10
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,16 @@ public function isEmpty()
553553
return empty($this->items);
554554
}
555555

556+
/**
557+
* Determine if the collection contains a single item.
558+
*
559+
* @return bool
560+
*/
561+
public function containsOneItem()
562+
{
563+
return $this->count() === 1;
564+
}
565+
556566
/**
557567
* Join all items from the collection using a string. The final items can use a separate glue string.
558568
*

LazyCollection.php

+10
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,16 @@ public function isEmpty()
556556
return ! $this->getIterator()->valid();
557557
}
558558

559+
/**
560+
* Determine if the collection contains a single item.
561+
*
562+
* @return bool
563+
*/
564+
public function containsOneItem()
565+
{
566+
return $this->take(2)->count() === 1;
567+
}
568+
559569
/**
560570
* Join all items from the collection using a string. The final items can use a separate glue string.
561571
*

0 commit comments

Comments
 (0)