Skip to content

Commit

Permalink
Added the count method (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonrietdijk authored Sep 27, 2023
1 parent 868539c commit a4f8bd4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ public function lazy(int $pageSize = null): LazyCollection
});
}

public function count(): int
{
/** @var ?int $count */
$count = $this->builder->take(1)->count();
$count ??= 0;

return $count;
}

public function limit(int $limit): static
{
$this->builder->take($limit);
Expand Down

0 comments on commit a4f8bd4

Please sign in to comment.