Skip to content

Commit

Permalink
fix: refresh count with criteria (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi authored Jun 18, 2024
1 parent 95e606a commit aae4d2b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
14 changes: 14 additions & 0 deletions packages/collections-domain/src/CriteriaRecollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,18 @@ protected function createFrom(
strict: $strict ?? $this->strict,
);
}

/**
* @return int<0,max>
*/
private function getRealCount(): int
{
$count = $this->collection->matching($this->criteria)->count();

if ($count > 0) {
return $count;
}

return 0;
}
}
14 changes: 14 additions & 0 deletions packages/collections-domain/src/Recollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,18 @@ protected function withCriteria(
strict: $this->strict,
);
}

/**
* @return int<0,max>
*/
private function getRealCount(): int
{
$count = $this->collection->count();

if ($count > 0) {
return $count;
}

return 0;
}
}
14 changes: 0 additions & 14 deletions packages/collections-domain/src/Trait/RecollectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,4 @@ private function getPageable(): PageableInterface

return $this->pageable;
}

/**
* @return int<0,max>
*/
private function getRealCount(): int
{
$count = $this->collection->count();

if ($count > 0) {
return $count;
}

return 0;
}
}

0 comments on commit aae4d2b

Please sign in to comment.