countItem = $options['countItem']; $this->perPage = $options['perPage'] ?? 10; $this->currentPage = $options['currentPage'] ?? 1; $this->baseUrl = $options['baseUrl'] ?? ''; $this->baseUrl .= $options['prefix'] ?? '/page'; $this->countPages = ceil($this->countItem / $this->perPage); } public function create(): void { $prev = $this->currentPage - 1 >= 1 ? $this->currentPage - 1 : null; $next = $this->currentPage + 1 <= $this->countPages ? $this->currentPage + 1 : null; $btns = $prev ? "
  • $prev
  • " : ""; $btns .= "
  • $this->currentPage
  • "; $btns .= $next ? "
  • $next
  • " : ""; $this->html = str_replace('{btns}', $btns, $this->getTemplate()); $this->html = str_replace('{previous_link}', $this->baseUrl . "/1", $this->html); $this->html = str_replace('{next_link}', $this->baseUrl . "/" . $this->countPages, $this->html); } public function render(): void { echo $this->html; } public function fetch(): string { return $this->html; } private function getTemplate(): string { return ''; } }