Skip to content

Commit 4ba3e48

Browse files
Avoid needing getPerPage and perPage
Co-Authored-By: Jeroen Thora <1374857+acrobat@users.noreply.github.com>
1 parent 54c652c commit 4ba3e48

16 files changed

+85
-136
lines changed

lib/Github/Api/AbstractApi.php

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
use Github\Client;
66
use Github\HttpClient\Message\ResponseMediator;
7-
use ValueError;
87

98
/**
109
* @author Joseph Bielawski <stloyd@gmail.com>
1110
* @author Graham Campbell <graham@alt-three.com>
1211
*/
13-
abstract class AbstractApi implements ApiInterface
12+
abstract class AbstractApi
1413
{
1514
/**
1615
* The client instance.
@@ -29,19 +28,13 @@ abstract class AbstractApi implements ApiInterface
2928
/**
3029
* Create a new API instance.
3130
*
32-
* @param Client $client
33-
* @param int|null $perPage
31+
* @param Client $client
3432
*
3533
* @return void
3634
*/
37-
public function __construct(Client $client, int $perPage = null)
35+
public function __construct(Client $client)
3836
{
39-
if (null !== $perPage && ($perPage < 1 || $perPage > 100)) {
40-
throw new ValueError(sprintf('%s::__construct(): Argument #2 ($perPage) must be between 1 and 100, or null', self::class));
41-
}
42-
4337
$this->client = $client;
44-
$this->perPage = $perPage;
4538
}
4639

4740
/**
@@ -64,38 +57,6 @@ protected function getApiVersion()
6457
return $this->client->getApiVersion();
6558
}
6659

67-
/**
68-
* Get the number of values to fetch per page.
69-
*
70-
* @return int|null
71-
*/
72-
protected function getPerPage()
73-
{
74-
return $this->perPage;
75-
}
76-
77-
/**
78-
* Create a new instance with the given page parameter.
79-
*
80-
* This must be an integer between 1 and 100.
81-
*
82-
* @param int|null $perPage
83-
*
84-
* @return static
85-
*/
86-
public function perPage(?int $perPage)
87-
{
88-
if (null !== $perPage && ($perPage < 1 || $perPage > 100)) {
89-
throw new ValueError(sprintf('%s::perPage(): Argument #1 ($perPage) must be between 1 and 100, or null', self::class));
90-
}
91-
92-
$copy = clone $this;
93-
94-
$copy->perPage = $perPage;
95-
96-
return $copy;
97-
}
98-
9960
public function configure()
10061
{
10162
}

lib/Github/Api/ApiInterface.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

lib/Github/Api/CurrentUser.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public function update(array $params)
3535
*/
3636
public function emails()
3737
{
38-
return new Emails($this->getClient(), $this->getPerPage());
38+
return new Emails($this->getClient());
3939
}
4040

4141
/**
4242
* @return Followers
4343
*/
4444
public function follow()
4545
{
46-
return new Followers($this->getClient(), $this->getPerPage());
46+
return new Followers($this->getClient());
4747
}
4848

4949
public function followers($page = 1)
@@ -71,23 +71,23 @@ public function issues(array $params = [], $includeOrgIssues = true)
7171
*/
7272
public function keys()
7373
{
74-
return new PublicKeys($this->getClient(), $this->getPerPage());
74+
return new PublicKeys($this->getClient());
7575
}
7676

7777
/**
7878
* @return Notifications
7979
*/
8080
public function notifications()
8181
{
82-
return new Notifications($this->getClient(), $this->getPerPage());
82+
return new Notifications($this->getClient());
8383
}
8484

8585
/**
8686
* @return Memberships
8787
*/
8888
public function memberships()
8989
{
90-
return new Memberships($this->getClient(), $this->getPerPage());
90+
return new Memberships($this->getClient());
9191
}
9292

9393
/**
@@ -147,15 +147,15 @@ public function repositories($type = 'owner', $sort = 'full_name', $direction =
147147
*/
148148
public function watchers()
149149
{
150-
return new Watchers($this->getClient(), $this->getPerPage());
150+
return new Watchers($this->getClient());
151151
}
152152

153153
/**
154154
* @return Starring
155155
*/
156156
public function starring()
157157
{
158-
return new Starring($this->getClient(), $this->getPerPage());
158+
return new Starring($this->getClient());
159159
}
160160

161161
/**

lib/Github/Api/Enterprise.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@ class Enterprise extends AbstractApi
2222
*/
2323
public function stats()
2424
{
25-
return new Stats($this->getClient(), $this->getPerPage());
25+
return new Stats($this->getClient());
2626
}
2727

2828
/**
2929
* @return License
3030
*/
3131
public function license()
3232
{
33-
return new License($this->getClient(), $this->getPerPage());
33+
return new License($this->getClient());
3434
}
3535

3636
/**
3737
* @return ManagementConsole
3838
*/
3939
public function console()
4040
{
41-
return new ManagementConsole($this->getClient(), $this->getPerPage());
41+
return new ManagementConsole($this->getClient());
4242
}
4343

4444
/**
4545
* @return UserAdmin
4646
*/
4747
public function userAdmin()
4848
{
49-
return new UserAdmin($this->getClient(), $this->getPerPage());
49+
return new UserAdmin($this->getClient());
5050
}
5151
}

lib/Github/Api/Gists.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,6 @@ public function unstar($id)
177177
*/
178178
public function comments()
179179
{
180-
return new Comments($this->getClient(), $this->getPerPage());
180+
return new Comments($this->getClient());
181181
}
182182
}

lib/Github/Api/GitData.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,38 @@ class GitData extends AbstractApi
2222
*/
2323
public function blobs()
2424
{
25-
return new Blobs($this->getClient(), $this->getPerPage());
25+
return new Blobs($this->getClient());
2626
}
2727

2828
/**
2929
* @return Commits
3030
*/
3131
public function commits()
3232
{
33-
return new Commits($this->getClient(), $this->getPerPage());
33+
return new Commits($this->getClient());
3434
}
3535

3636
/**
3737
* @return References
3838
*/
3939
public function references()
4040
{
41-
return new References($this->getClient(), $this->getPerPage());
41+
return new References($this->getClient());
4242
}
4343

4444
/**
4545
* @return Tags
4646
*/
4747
public function tags()
4848
{
49-
return new Tags($this->getClient(), $this->getPerPage());
49+
return new Tags($this->getClient());
5050
}
5151

5252
/**
5353
* @return Trees
5454
*/
5555
public function trees()
5656
{
57-
return new Trees($this->getClient(), $this->getPerPage());
57+
return new Trees($this->getClient());
5858
}
5959
}

lib/Github/Api/Issue.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function unlock($username, $repository, $id)
176176
*/
177177
public function comments()
178178
{
179-
return new Comments($this->getClient(), $this->getPerPage());
179+
return new Comments($this->getClient());
180180
}
181181

182182
/**
@@ -188,7 +188,7 @@ public function comments()
188188
*/
189189
public function events()
190190
{
191-
return new Events($this->getClient(), $this->getPerPage());
191+
return new Events($this->getClient());
192192
}
193193

194194
/**
@@ -200,7 +200,7 @@ public function events()
200200
*/
201201
public function labels()
202202
{
203-
return new Labels($this->getClient(), $this->getPerPage());
203+
return new Labels($this->getClient());
204204
}
205205

206206
/**
@@ -212,7 +212,7 @@ public function labels()
212212
*/
213213
public function milestones()
214214
{
215-
return new Milestones($this->getClient(), $this->getPerPage());
215+
return new Milestones($this->getClient());
216216
}
217217

218218
/**
@@ -224,7 +224,7 @@ public function milestones()
224224
*/
225225
public function assignees()
226226
{
227-
return new Assignees($this->getClient(), $this->getPerPage());
227+
return new Assignees($this->getClient());
228228
}
229229

230230
/**
@@ -236,6 +236,6 @@ public function assignees()
236236
*/
237237
public function timeline()
238238
{
239-
return new Timeline($this->getClient(), $this->getPerPage());
239+
return new Timeline($this->getClient());
240240
}
241241
}

lib/Github/Api/Organization.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,31 +82,31 @@ public function repositories($organization, $type = 'all', $page = 1, $sort = nu
8282
*/
8383
public function members()
8484
{
85-
return new Members($this->getClient(), $this->getPerPage());
85+
return new Members($this->getClient());
8686
}
8787

8888
/**
8989
* @return Hooks
9090
*/
9191
public function hooks()
9292
{
93-
return new Hooks($this->getClient(), $this->getPerPage());
93+
return new Hooks($this->getClient());
9494
}
9595

9696
/**
9797
* @return Teams
9898
*/
9999
public function teams()
100100
{
101-
return new Teams($this->getClient(), $this->getPerPage());
101+
return new Teams($this->getClient());
102102
}
103103

104104
/**
105105
* @return OutsideCollaborators
106106
*/
107107
public function outsideCollaborators()
108108
{
109-
return new OutsideCollaborators($this->getClient(), $this->getPerPage());
109+
return new OutsideCollaborators($this->getClient());
110110
}
111111

112112
/**

lib/Github/Api/Project/AbstractProjectApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public function deleteProject($id)
4040

4141
public function columns()
4242
{
43-
return new Columns($this->getClient(), $this->getPerPage());
43+
return new Columns($this->getClient());
4444
}
4545
}

lib/Github/Api/Project/Columns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ public function move($id, array $params)
6868

6969
public function cards()
7070
{
71-
return new Cards($this->getClient(), $this->getPerPage());
71+
return new Cards($this->getClient());
7272
}
7373
}

lib/Github/Api/PullRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ public function status($username, $repository, $id)
110110

111111
public function comments()
112112
{
113-
return new Comments($this->getClient(), $this->getPerPage());
113+
return new Comments($this->getClient());
114114
}
115115

116116
public function reviews()
117117
{
118-
return new Review($this->getClient(), $this->getPerPage());
118+
return new Review($this->getClient());
119119
}
120120

121121
public function reviewRequests()
122122
{
123-
return new ReviewRequest($this->getClient(), $this->getPerPage());
123+
return new ReviewRequest($this->getClient());
124124
}
125125

126126
/**

0 commit comments

Comments
 (0)