blob: 67708abd4eab5e3c66298c92ec5d3aaa95d94839 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
}
}
|