tleckie / paginator
PHP - Simple paginator class and interface
Fund package maintenance!
teodoroleckie
www.paypal.com/donate?business=ZHYA2MTGA4884¤cy_code=USD
Requires
- php: ^8
Requires (Dev)
- friendsofphp/php-cs-fixer: v3.0.0-beta.2
- infection/infection: ^0.21.5
- phpunit/phpunit: ^9.5
README
Enumerator in php
Installation
You can install the package via composer:
composer require tleckie/paginator
Usage:
<?php require_once "vendor/autoload.php"; use Tleckie\Paginator\Paginator; $paginator = new Paginator(100,10, 2); $paginator->getTotalPages();// 10 $paginator->getLastPage(); // 10 $paginator->getOffset(); // 10 $paginator->getPrevPage(); // 1 $paginator->getNextPage(); // 3 $paginator->hasNext(); // true $paginator->hasPrev(); // true
Interface:
PaginatorInterface
All methods:
public function getTotalRecords(): int; public function getItemsPerPage(): int; public function getCurrentPage(): int; public function setCurrentPage(int $currentPage): PaginatorInterface; public function setTotalRecords(int $totalRecords): PaginatorInterface; public function setItemsPerPage(int $itemsPerPage): PaginatorInterface; public function hasPrev(): bool; public function hasNext(): bool; public function getNextPage(): int; public function getPrevPage(): int; public function getLastPage(): int; public function getFirstPage(): int; public function getOffset(): int; public function getTotalPages(): int;