diff options
Diffstat (limited to 'Digitigrade/Timeline.php')
| -rw-r--r-- | Digitigrade/Timeline.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Digitigrade/Timeline.php b/Digitigrade/Timeline.php new file mode 100644 index 0000000..67708ab --- /dev/null +++ b/Digitigrade/Timeline.php @@ -0,0 +1,29 @@ +<?php +namespace Digitigrade; + +use Digitigrade\Model\Note; + +abstract class Timeline { + // TODO: currently making this number up. probably should be modifiable somewhere + 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[] + */ + protected abstract function getNoteIds(int $limit, int $offset): array; + + /** + * Gets a pageful of notes that are included in this timeline + * @param int $page page number to return (0-indexed) + * @return Note[] + */ + 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); + } +}
\ No newline at end of file |
