tuupola/beeper

Generic paginator for PHP 5.4+

0.3.1 2016-10-22 09:00 UTC

README

Generic pager for PHP 5.4+

Author Software License Build Status HHVM 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()
    ->next()
    ->next();

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