Exemple #1
0
<?php

$p = new \ebi\Paginator(4, 1, 3);
eq(1, $p->first());
eq(1, $p->last());
eq(false, $p->has_range());
$p = new \ebi\Paginator(4, 2, 3);
eq(1, $p->first());
eq(1, $p->last());
eq(false, $p->has_range());
$p = new \ebi\Paginator(4, 1, 10);
eq(1, $p->first());
eq(3, $p->last());
eq(true, $p->has_range());
$p = new \ebi\Paginator(4, 2, 10);
eq(1, $p->first());
eq(3, $p->last());
eq(true, $p->has_range());
Exemple #2
0
eq(10, $p->which_last(3));
$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());