1 | <?php |
||
5 | class Pagination |
||
6 | { |
||
7 | /** |
||
8 | * Iterate through results of Api function call. By |
||
9 | * default generator will return all pagination results. |
||
10 | * To limit result batches, set $batchesLimit. Call function |
||
11 | * of object to get data. |
||
12 | * |
||
13 | * @param callable $callback |
||
14 | * @param array $params |
||
15 | * @param int $batchesLimit |
||
16 | * @return \Iterator |
||
17 | */ |
||
18 | public static function getPaginatedData($callback, $params, $batchesLimit = 0) |
||
38 | |||
39 | protected static function getPaginatedResponse(callable $callback, array $params) |
||
48 | |||
49 | protected static function getDataFromPaginatedResponse($response) |
||
59 | |||
60 | /** |
||
61 | * @param array $res |
||
62 | * @return bool |
||
63 | */ |
||
64 | protected static function responseHasData($res) |
||
68 | |||
69 | /** |
||
70 | * Check if we get batches limit in pagination |
||
71 | * @param int $batchesLimit |
||
72 | * @param int $batchesNum |
||
73 | * @return bool |
||
74 | */ |
||
75 | protected static function reachBatchesLimit($batchesLimit, $batchesNum) |
||
79 | |||
80 | /** |
||
81 | * Remove 'module' data from response |
||
82 | * @param array $res |
||
83 | * @return array mixed |
||
84 | */ |
||
85 | protected static function clearResponseFromMetaData($res) |
||
93 | |||
94 | /** |
||
95 | * @param $response |
||
96 | * @return array |
||
97 | */ |
||
98 | protected static function getBookMarks($response) |
||
102 | |||
103 | protected static function checkEndBookMarks($bookmarks) |
||
107 | } |
||
108 |