Skip to content

teodoroleckie/paginator

Repository files navigation

Php paginator

Scrutinizer Code Quality Build Status Total Downloads Code Intelligence Status

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;