Skip to content

Commit

Permalink
Support Collection#countBy($key) (#33852)
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephSilber authored Aug 13, 2020
1 parent 9b0c0af commit 0adb41f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ public function crossJoin(...$arrays)
*/
public function countBy($countBy = null)
{
if (is_null($countBy)) {
$countBy = $this->identity();
}
$countBy = is_null($countBy)
? $this->identity()
: $this->valueRetriever($countBy);

return new static(function () use ($countBy) {
$counts = [];
Expand Down

0 comments on commit 0adb41f

Please sign in to comment.