Skip to content

Commit 81aa33e

Browse files
committed
Closes #177 - use the magic __call method for IDE completion
1 parent 4c5fe77 commit 81aa33e

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

lib/Github/Client.php

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,34 @@
1010
/**
1111
* Simple yet very cool PHP GitHub client
1212
*
13+
* @method Api\CurrentUser currentUser()
14+
* @method Api\CurrentUser me()
15+
* @method Api\Enterprise ent()
16+
* @method Api\Enterprise enterprise()
17+
* @method Api\GitData git()
18+
* @method Api\GitData gitData()
19+
* @method Api\Gists gist()
20+
* @method Api\Gists gists()
21+
* @method Api\Issue issue()
22+
* @method Api\Issue issues()
23+
* @method Api\Markdown markdown()
24+
* @method Api\Organization organization()
25+
* @method Api\Organization organizations()
26+
* @method Api\PullRequest pr()
27+
* @method Api\PullRequest pullRequest()
28+
* @method Api\PullRequest pullRequests()
29+
* @method Api\Repo repo()
30+
* @method Api\Repo repos()
31+
* @method Api\Repo repository()
32+
* @method Api\Repo repositories()
33+
* @method Api\Organization team()
34+
* @method Api\Organization teams()
35+
* @method Api\User user()
36+
* @method Api\User users()
37+
* @method Api\Authorizations authorization()
38+
* @method Api\Authorizations authorizations()
39+
* @method Api\Meta meta()
40+
*
1341
* @author Joseph Bielawski <stloyd@gmail.com>
1442
*
1543
* Website: http://github.com/KnpLabs/php-github-api
@@ -274,4 +302,86 @@ public function getSupportedApiVersions()
274302
{
275303
return array('v3', 'beta');
276304
}
305+
306+
/**
307+
* @param string $name
308+
*
309+
* @return ApiInterface
310+
*
311+
* @throws InvalidArgumentException
312+
*/
313+
public function __call($name) {
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;
386+
}
277387
}

0 commit comments

Comments
 (0)