Example #1
0
$p = new \ebi\Paginator(3, 2);
$list = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
foreach ($list as $v) {
    $p->add($v);
}
eq(array(4, 5, 6), $p->contents());
eq(2, $p->current());
eq(1, $p->first());
eq(3, $p->last());
eq(9, $p->total());
$p = new \ebi\Paginator(3, 2);
$list = array(1, 2, 3, 4, 5);
foreach ($list as $v) {
    $p->add($v);
}
eq(array(4, 5), $p->contents());
eq(2, $p->current());
eq(1, $p->first());
eq(2, $p->last());
eq(5, $p->total());
$p = new \ebi\Paginator(3);
$list = array(1, 2);
foreach ($list as $v) {
    $p->add($v);
}
eq(array(1, 2), $p->contents());
eq(1, $p->current());
eq(1, $p->first());
eq(1, $p->last());
eq(2, $p->total());
Example #2
0
<?php

$p = new \ebi\Paginator(10, 3);
$p->total(100);
$re = [];
foreach ($p as $k => $v) {
    $re[$k] = $v;
}
eq(array('current' => 3, 'limit' => 10, 'offset' => 20, 'total' => 100, 'order' => null), $re);