Centum\Paginator
The Paginator component is used for paginating large amounts of data practically.
How data is stored
Data is encapsulated in a class implementing Centum\Interfaces\Paginator\DataInterface
. It is designed such that the entire dataset can be contained within a DataInterface
object or can be retreived as and when it is needed.
DataInterface
has 3 public methods:
getTotal(): int
toArray(): array
slice(int $offset, int $length): array
For data contained within a simple array, Centum\Paginator\Data\ArrayData
will suffice.
Paginating
Centum\Paginator\Paginator
is the main class of the Paginator component.
Centum\Paginator\Paginator(
Centum\Interfaces\Paginator\DataInterface $data,
int $itemsPerPage,
string $urlPrefix
);
Centum\Paginator\Paginator
implements Centum\Interfaces\Paginator\PaginatorInterface
.
Centum\Paginator\Paginator
has 6 public methods:
getData(): Centum\Interfaces\Paginator\DataInterface
getItemsPerPage(): int
getUrlPrefix(): string
getTotalItems(): int
getTotalPages(): int
getPage(int $pageNumber): Centum\Interfaces\Paginator\PageInterface
Paginator
is responsible for creating Centum\Paginator\Page
objects that represent a page of data.
Centum\Paginator\Page(
Centum\Interfaces\Paginator\PaginatorInterface $paginator,
int $pageNumber
);
Centum\Paginator\Page
implements Centum\Interfaces\Paginator\PageInterface
.
Centum\Paginator\Page
has several public methods:
getPaginator(): Centum\Interfaces\Paginator\PaginatorInterface
getPageNumber(): int
getData(): array
getPreviousPageNumber(): int|null
getNextPageNumber(): int|null
getPageRange(int $i): array