Skip to content

Commit 1457455

Browse files
committed
Api: added paginator()
1 parent cf4044a commit 1457455

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/Github/Api.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,25 @@ public function decode(Http\Response $response, array $okCodes = NULL)
286286
}
287287

288288

289+
/**
290+
* Creates paginator for HTTP GET requests.
291+
*
292+
* @see get()
293+
*
294+
* @param string
295+
* @return Paginator
296+
*
297+
* @throws MissingParameterException
298+
*/
299+
public function paginator($urlPath, array $parameters = [], array $headers = [])
300+
{
301+
return new Paginator(
302+
$this,
303+
$this->createRequest(Http\Request::GET, $urlPath, $parameters, $headers)
304+
);
305+
}
306+
307+
289308
/**
290309
* @return Http\IClient
291310
*/

tests/Github/Api.phpt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,12 @@ test(function() {
135135
$request = $api->createRequest('', 'path', ['foo' => 'fuzz'], [], NULL);
136136
Assert::same('url://test/path?foo=fuzz', $request->getUrl());
137137
});
138+
139+
140+
# Paginator
141+
test(function() {
142+
$client = new MockIClient;
143+
$api = new TestApi($client);
144+
145+
Assert::type('Milo\Github\Paginator', $api->paginator(''));
146+
});

0 commit comments

Comments
 (0)