diff options
Diffstat (limited to 'Digitigrade/Timeline.php')
| -rw-r--r-- | Digitigrade/Timeline.php | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/Digitigrade/Timeline.php b/Digitigrade/Timeline.php index 67708ab..64aabe1 100644 --- a/Digitigrade/Timeline.php +++ b/Digitigrade/Timeline.php @@ -8,22 +8,19 @@ abstract class Timeline { private const RESULTS_PER_PAGE = 50; /** - * Gets a pageful of note IDs to be included in this timeline - * @param int $limit maximum number of results to return - * @param int $offset number of results to skip (i.e. results from previous pages) - * @return int[] + * Gets a pageful of items to be included in the timeline + * @param int $page page number to return (0-indexed) + * @return TimelineItem[] */ - protected abstract function getNoteIds(int $limit, int $offset): array; + public function getPage(int $page = 0): array { + return $this->getItems(self::RESULTS_PER_PAGE, self::RESULTS_PER_PAGE * $page); + } /** - * Gets a pageful of notes that are included in this timeline - * @param int $page page number to return (0-indexed) - * @return Note[] + * Gets a selection of items to be included in the timeline + * @param int $limit max number of items to return + * @param int $offset number of items to skip at first + * @return TimelineItem[] */ - public function getNotes(int $page = 0): array { - $ids = $this->getNoteIds(self::RESULTS_PER_PAGE, self::RESULTS_PER_PAGE * $page); - return array_map(function (int $id) { - return Note::find($id); - }, $ids); - } + abstract protected function getItems(int $limit, int $offset): array; }
\ No newline at end of file |
