ecommit/paginator

Create a paginator.

v1.2.0 2024-12-14 15:06 UTC

This package is auto-updated.

Last update: 2024-12-14 15:07:50 UTC


README

Create a paginator.

Tests

Installation

To install paginator with Composer just run :

$ composer require ecommit/paginator

Usage

use Ecommit\Paginator\ArrayPaginator;

//Create a paginator
$paginator = new ArrayPaginator([
    //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 ($paginator as $result) {
    //...
}

Available options

Available methods

See API documentation

License

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