Skip to content

Commit

Permalink
fix(PagerFantaAdapterAdapter): rename $pagerfanta to $adapter (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi authored Jun 23, 2024
1 parent 05d7b28 commit e1cb687
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

# 0.12.2

* fix(`PagerFantaAdapterAdapter`): rename `$pagerfanta` to `$adapter`

# 0.12.1

* fix: remove all `array_is_list()` checks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
final class PagerfantaAdapterAdapter implements OffsetPaginationAdapterInterface
{
/**
* @param AdapterInterface<T> $pagerfanta
* @param AdapterInterface<T> $adapter
*/
public function __construct(
private readonly AdapterInterface $pagerfanta,
private readonly AdapterInterface $adapter,
private readonly string|null $indexBy = null,
) {
}

public function getOffsetItems(int $offset, int $limit): array
{
/** @psalm-suppress InvalidArgument */
$items = iterator_to_array($this->pagerfanta->getSlice($offset, $limit));
$items = iterator_to_array($this->adapter->getSlice($offset, $limit));

if ($this->indexBy !== null) {
$newItems = [];
Expand All @@ -59,7 +59,7 @@ public function countOffsetItems(int $offset = 0, ?int $limit = null): ?int
return null;
}

$slice = $this->pagerfanta->getSlice($offset, $limit);
$slice = $this->adapter->getSlice($offset, $limit);
$count = 0;

foreach ($slice as $item) {
Expand All @@ -71,6 +71,6 @@ public function countOffsetItems(int $offset = 0, ?int $limit = null): ?int

public function countItems(): int
{
return $this->pagerfanta->getNbResults();
return $this->adapter->getNbResults();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(
) {
$this->pageable = new OffsetPageable(
adapter: new PagerfantaAdapterAdapter(
pagerfanta: $pagerfanta->getAdapter(),
adapter: $pagerfanta->getAdapter(),
indexBy: $indexBy,
),
itemsPerPage: $pagerfanta->getMaxPerPage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function generatePageable(

$pagerfantaAdapter = new SelectableAdapter($user->getPosts(), $criteria);
$adapter = new PagerfantaAdapterAdapter(
pagerfanta: $pagerfantaAdapter,
adapter: $pagerfantaAdapter,
indexBy: 'id',
);

Expand Down

0 comments on commit e1cb687

Please sign in to comment.