Skip to content

Commit af024a6

Browse files
committed
Make use of the api method and move the camelCase aliases into it
1 parent 34b5186 commit af024a6

File tree

1 file changed

+5
-72
lines changed

1 file changed

+5
-72
lines changed

lib/Github/Client.php

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function api($name)
112112
switch ($name) {
113113
case 'me':
114114
case 'current_user':
115+
case 'currentUser':
115116
$api = new Api\CurrentUser($this);
116117
break;
117118

@@ -122,6 +123,7 @@ public function api($name)
122123

123124
case 'git':
124125
case 'git_data':
126+
case 'gitData':
125127
$api = new Api\GitData($this);
126128
break;
127129

@@ -145,7 +147,9 @@ public function api($name)
145147
break;
146148

147149
case 'pr':
150+
case 'pullRequest':
148151
case 'pull_request':
152+
case 'pullRequests':
149153
case 'pull_requests':
150154
$api = new Api\PullRequest($this);
151155
break;
@@ -311,77 +315,6 @@ public function getSupportedApiVersions()
311315
* @throws InvalidArgumentException
312316
*/
313317
public function __call($name, $args) {
314-
switch ($name) {
315-
case 'me':
316-
case 'currentUser':
317-
$api = new Api\CurrentUser($this);
318-
break;
319-
320-
case 'ent':
321-
case 'enterprise':
322-
$api = new Api\Enterprise($this);
323-
break;
324-
325-
case 'git':
326-
case 'gitData':
327-
$api = new Api\GitData($this);
328-
break;
329-
330-
case 'gist':
331-
case 'gists':
332-
$api = new Api\Gists($this);
333-
break;
334-
335-
case 'issue':
336-
case 'issues':
337-
$api = new Api\Issue($this);
338-
break;
339-
340-
case 'markdown':
341-
$api = new Api\Markdown($this);
342-
break;
343-
344-
case 'organization':
345-
case 'organizations':
346-
$api = new Api\Organization($this);
347-
break;
348-
349-
case 'pr':
350-
case 'pullRequest':
351-
case 'pullRequests':
352-
$api = new Api\PullRequest($this);
353-
break;
354-
355-
case 'repo':
356-
case 'repos':
357-
case 'repository':
358-
case 'repositories':
359-
$api = new Api\Repo($this);
360-
break;
361-
362-
case 'team':
363-
case 'teams':
364-
$api = new Api\Organization\Teams($this);
365-
break;
366-
367-
case 'user':
368-
case 'users':
369-
$api = new Api\User($this);
370-
break;
371-
372-
case 'authorization':
373-
case 'authorizations':
374-
$api = new Api\Authorizations($this);
375-
break;
376-
377-
case 'meta':
378-
$api = new Api\Meta($this);
379-
break;
380-
381-
default:
382-
throw new InvalidArgumentException(sprintf('Undefined api instance called: "%s"', $name));
383-
}
384-
385-
return $api;
318+
return $this->api($name);
386319
}
387320
}

0 commit comments

Comments
 (0)