Skip to content

Repository files navigation

Paginator

Create a paginator.

Tests

Installation

To install paginator with Composer just run :

$ composer require ecommit/paginator

Usage

useEcommit\Paginator\ArrayPaginator;
//Create a paginator$paginator = newArrayPaginator([
//Options'page' => 1,
'max_per_page' => 100,
'data' => ['val1', 'val2', 'val3'],
//Or with an ArrayIterator//'data' => new \ArrayIterator(['val1', 'val2', 'val3']),
]);
$totalPages = $paginator->getLastPage();
$countRows = \count($paginator);
foreach ($paginatoras$result) {
//...
}

Available options

OptionTypeRequiredDefault valueDescription
pageIntegerNo1Current page
max_per_pageIntegerNo100Max elements per page
dataArray or ArrayIteratorYes
  • If count option is null : All data (of all pages)
  • If count option is not null : Only the data to display on the current page
countInteger or nullNoNullYou can use this option when the data volume is too large. If the value is not null :
  • It must equal the total number of results
  • The data option must contain only the data to display on the current page

Available methods

See API documentation

License

This librairy is under the MIT license. See the complete license in LICENSE file.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages