Skip to content

Commit

Permalink
fix: PrecountingStrategy now accepts null as the underlying data (#134
Browse files Browse the repository at this point in the history
)
  • Loading branch information
priyadi authored Jul 26, 2024
1 parent c3a9a96 commit 996212a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## 0.11.0
## 0.11.2

* fix: `PrecountingStrategy` now accepts null as the underlying data

## 0.11.1

* docs: update readme
* feat: offset pagination support
Expand Down
6 changes: 3 additions & 3 deletions packages/collections-common/src/Count/PrecountingStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
class PrecountingStrategy implements CountStrategy
{
/**
* @param int<0,max> $count
* @param ?int<0,max> $count
*/
public function __construct(private int &$count)
public function __construct(private ?int &$count)
{
}

#[\Override]
public function getCount(?\Countable $underlyingObject): int
{
return $this->count;
return $this->count ?? 0;
}

#[\Override]
Expand Down

0 comments on commit 996212a

Please sign in to comment.