totalItems = $totalItems; $this->perPage = $perPage; $this->currentPage = max(1, $currentPage); $this->totalPages = (int)ceil($totalItems / $perPage); $this->start = ($this->currentPage - 1) * $perPage; $this->end = min($this->start + $perPage, $totalItems); $this->groupSize = intval(VIEW_LIST_PAGINATION_GROUPSIZE); } public function hasPrevious(): bool { return $this->currentPage > 1; } public function hasNext(): bool { return $this->currentPage < $this->totalPages; } public function previousPage(): int { return max(1, $this->currentPage - 1); } public function nextPage(): int { return min($this->totalPages, $this->currentPage + 1); } public function getOffset(): int { return $this->start; } public function getLimit(): int { return $this->perPage; } public function toArray(): array { return [ 'current_page' => $this->currentPage, 'per_page' => $this->perPage, 'total_items' => $this->totalItems, 'total_pages' => $this->totalPages, 'has_previous' => $this->hasPrevious(), 'has_next' => $this->hasNext(), 'previous_page' => $this->previousPage(), 'next_page' => $this->nextPage(), 'offset' => $this->getOffset(), 'limit' => $this->getLimit(), ]; } public function render(string $baseUrl = '', array $query = []): string { if ($this->totalPages <= 1) { return ''; } $html = ''; return $html; } private function pageLink(int $page, string $label, string $baseUrl, array $query): string { $query['curPage'] = $page; $url = $baseUrl . '?' . http_build_query($query); return '
  • ' . $label . '
  • '; } }