Skip to content

Commit

Permalink
Replace result type of PaginatorInterface::with* methods to static (
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Dec 17, 2022
1 parent 98fbdff commit d7acb58
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Paginator/KeysetPaginator.php
Expand Up @@ -114,23 +114,23 @@ public function __clone()
$this->currentLastValue = null;
}

public function withNextPageToken(?string $token): self
public function withNextPageToken(?string $token): static
{
$new = clone $this;
$new->firstValue = null;
$new->lastValue = $token;
return $new;
}

public function withPreviousPageToken(?string $token): self
public function withPreviousPageToken(?string $token): static
{
$new = clone $this;
$new->firstValue = $token;
$new->lastValue = null;
return $new;
}

public function withPageSize(int $pageSize): self
public function withPageSize(int $pageSize): static
{
if ($pageSize < 1) {
throw new InvalidArgumentException('Page size should be at least 1.');
Expand Down
6 changes: 3 additions & 3 deletions src/Paginator/OffsetPaginator.php
Expand Up @@ -61,17 +61,17 @@ public function __construct(ReadableDataInterface $dataReader)
$this->dataReader = $dataReader;
}

public function withNextPageToken(?string $token): self
public function withNextPageToken(?string $token): static
{
return $this->withCurrentPage((int) $token);
}

public function withPreviousPageToken(?string $token): self
public function withPreviousPageToken(?string $token): static
{
return $this->withCurrentPage((int) $token);
}

public function withPageSize(int $pageSize): self
public function withPageSize(int $pageSize): static
{
if ($pageSize < 1) {
throw new PaginatorException('Page size should be at least 1.');
Expand Down
6 changes: 3 additions & 3 deletions src/Paginator/PaginatorInterface.php
Expand Up @@ -14,11 +14,11 @@ interface PaginatorInterface
{
public const DEFAULT_PAGE_SIZE = 10;

public function withNextPageToken(?string $token): self;
public function withNextPageToken(?string $token): static;

public function withPreviousPageToken(?string $token): self;
public function withPreviousPageToken(?string $token): static;

public function withPageSize(int $pageSize): self;
public function withPageSize(int $pageSize): static;

public function getNextPageToken(): ?string;

Expand Down

0 comments on commit d7acb58

Please sign in to comment.