Skip to content

Commit

Permalink
#210 Some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
simba77 committed Mar 30, 2022
1 parent 0887bb4 commit 538e020
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions system/src/Utility/Pagination.php
Expand Up @@ -23,16 +23,12 @@ public function __construct(int $total, ?int $perPage = null, string $pageParamN
$this->total = $total;
$this->pageParamName = $pageParamName;
$this->request = di(Request::class);
if (! $perPage) {
$this->perPage = di(SiteSettings::class)->getPerPage();
} else {
$this->perPage = $perPage;
}
$this->setPerPage($perPage);
$this->setCurrentPage($currentPage);
$this->pagination = new \Compolomus\Pagination\Pagination($this->currentPage, $this->perPage, $this->total, 2);
}

public function setCurrentPage(?int $currentPage = null): static
private function setCurrentPage(?int $currentPage = null): void
{
if ($currentPage) {
$this->currentPage = $currentPage;
Expand All @@ -42,7 +38,15 @@ public function setCurrentPage(?int $currentPage = null): static
$this->currentPage = 1;
}
}
return $this;
}

private function setPerPage(?int $perPage): void
{
if (! $perPage) {
$this->perPage = di(SiteSettings::class)->getPerPage();

This comment has been minimized.

Copy link
@ging-dev

ging-dev Mar 30, 2022

Contributor

How about

$this->perPage = $perPage ?? di(...)->getPerPage();
} else {
$this->perPage = $perPage;
}
}

private function buildUrl(int $page): string
Expand Down

0 comments on commit 538e020

Please sign in to comment.