| Conditions | 8 |
| Paths | 13 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | public static function getPaginatedData($obj, $function, $params, $batchesLimit = 0) |
||
| 20 | { |
||
| 21 | $batchesNum = 0; |
||
| 22 | do { |
||
| 23 | if (self::reachBatchesLimit($batchesLimit, $batchesNum)) break; |
||
| 24 | |||
| 25 | $items = []; |
||
| 26 | $res = call_user_func_array([$obj, $function], $params); |
||
| 27 | |||
| 28 | if (self::_responseHasData($res)) { |
||
| 29 | if (isset($res['data'][0]['type']) && $res['data'][0]['type'] == 'module') { |
||
| 30 | array_shift($res['data']); |
||
| 31 | } |
||
| 32 | $items = $res['data']; |
||
| 33 | } |
||
| 34 | |||
| 35 | if (isset($res['bookmarks'])) { |
||
| 36 | $params['bookmarks'] = $res['bookmarks']; |
||
| 37 | } |
||
| 38 | |||
| 39 | if (empty($items)) return; |
||
| 40 | |||
| 41 | $batchesNum++; |
||
| 42 | yield $items; |
||
| 43 | } while (self::_responseHasData($res)); |
||
| 44 | } |
||
| 45 | |||
| 66 |