Skip to content

Commit a8246f3

Browse files
committed
ci: Generate code
1 parent 8d6acec commit a8246f3

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/Paginator.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,35 @@
44

55
class Paginator
66
{
7-
private $request;
7+
private $callable;
88
private $params;
99
private $pagination_cache = [];
1010
private const FIRST_PAGE = "FIRST_PAGE";
1111

12-
public function __construct(callable $request, array $params = [])
12+
public function __construct(callable $callable, array $params = [])
1313
{
14-
$this->request = $request;
14+
$this->callable = $callable;
1515
$this->params = $params;
1616
}
1717

1818
public function firstPage(): array
1919
{
20-
$request = $this->request;
20+
$callable = $this->callable;
2121
$params = $this->params;
2222

2323
$params["on_response"] = fn($response) => $this->cachePagination(
2424
$response,
2525
self::FIRST_PAGE
2626
);
2727

28-
$data = $request($params);
28+
$data = $callable($params);
2929

3030
return [$data, $this->pagination_cache[self::FIRST_PAGE]];
3131
}
3232

3333
public function nextPage(string $next_page_cursor): array
3434
{
35-
if ($next_page_cursor === null) {
36-
throw new \InvalidArgumentException(
37-
"Cannot get the next page with a null next_page_cursor"
38-
);
39-
}
40-
41-
$request = $this->request;
35+
$callable = $this->callable;
4236
$params = $this->params;
4337

4438
$params["page_cursor"] = $next_page_cursor;
@@ -47,7 +41,7 @@ public function nextPage(string $next_page_cursor): array
4741
$next_page_cursor
4842
);
4943

50-
$data = $request($params);
44+
$data = $callable($params);
5145

5246
return [$data, $this->pagination_cache[$next_page_cursor]];
5347
}

0 commit comments

Comments
 (0)