Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: change PageableInterface::getPageIdentifierClass() from static to instance method to simplify decoration #75

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

# 0.11.0

* refactor: change `PageableInterface::getPageIdentifierClass()` from static to
instance method to simplify decoration

# 0.10.1

* chore: remove unneeded intermediate interfaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getPage(
}

$pageIdentifierEncoder = $this->pageIdentifierEncoderLocator
->getPageIdentifierEncoder($pageable::getPageIdentifierClass());
->getPageIdentifierEncoder($pageable->getPageIdentifierClass());

$iri = $this->getIriFromContext($context);
$encodedPageIdentifier = $this->getEncodedPageIdentifierFromIri($iri);
Expand Down
2 changes: 1 addition & 1 deletion packages/rekapager-contracts/src/PageableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getPageByIdentifier(object $pageIdentifier): PageInterface;
/**
* @return class-string
*/
public static function getPageIdentifierClass(): string;
public function getPageIdentifierClass(): string;

/**
* @return PageInterface<TKey,T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function withItemsPerPage(int $itemsPerPage): static
return $new;
}

public static function getPageIdentifierClass(): string
public function getPageIdentifierClass(): string
{
return KeysetPageIdentifier::class;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function withItemsPerPage(int $itemsPerPage): static
return $new;
}

public static function getPageIdentifierClass(): string
public function getPageIdentifierClass(): string
{
return PageNumber::class;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function getPageByIdentifier(object $pageIdentifier): PageInterface
return $this->pageable->getPageByIdentifier($pageIdentifier);
}

public static function getPageIdentifierClass(): string
public function getPageIdentifierClass(): string
{
return OffsetPageable::getPageIdentifierClass();
return $this->pageable->getPageIdentifierClass();
}

public function getPages(): \Traversable
Expand Down
Loading