Home

Awesome

Beeper

Generic pager for PHP 7.1+

Latest Version Packagist Software License Build Status Coverage

Install

You can install latest version using composer.

$ composer require tuupola/beeper

Usage

use Beeper\Adapter\ArrayAdapter;
use Beeper\Beeper;

$array = range(1, 12, 1);
$adapter = new ArrayAdapter($array);

$beeper = new Beeper(["adapter" => $adapter, "size" => 5, "page" => 1]);

foreach ($beeper as $key => $page) {
    print_r($page);
}
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
)
Array
(
    [0] => 6
    [1] => 7
    [2] => 8
    [3] => 9
    [4] => 10
)
Array
(
    [0] => 11
    [1] => 12
)
$beeper->rewind();
$beeper->next();
$beeper->next();

print_r($beeper->get());
Array
(
    [0] => 11
    [1] => 12
)