class ArrayPaginator
{
public function getPaginatedList(array $data, int $page, int $limit): array
{
if (false === $this->isValidPaginationInput($page, $limit)) {
return [];
}
$offset = ($page - 1) * $limit;
return array_slice($data, $offset, $limit);
}
private function isValidPaginationInput(int $page, int $limit): bool
{
return $page > 0 && $limit > 0;
}
}