1 | <?php |
||
5 | trait PaginationHelper |
||
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 function getPaginatedData($callback, $params, $batchesLimit = 0) |
||
42 | |||
43 | /** |
||
44 | * @param array $res |
||
45 | * @return bool |
||
46 | */ |
||
47 | protected function _responseHasData($res) |
||
51 | |||
52 | /** |
||
53 | * Check if we get batches limit in pagination |
||
54 | * @param int $batchesLimit |
||
55 | * @param int $batchesNum |
||
56 | * @return bool |
||
57 | */ |
||
58 | protected function reachBatchesLimit($batchesLimit, $batchesNum) |
||
62 | |||
63 | /** |
||
64 | * Remove 'module' data from response |
||
65 | * @param array $res |
||
66 | * @return array mixed |
||
67 | */ |
||
68 | protected function _clearResponseFromMetaData($res) |
||
76 | } |
||
77 |