Skip to content

Closes #177 - use the magic __call method for IDE completion #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 21, 2014
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions lib/Github/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,34 @@
/**
* Simple yet very cool PHP GitHub client
*
* @method Api\CurrentUser currentUser()
* @method Api\CurrentUser me()
* @method Api\Enterprise ent()
* @method Api\Enterprise enterprise()
* @method Api\GitData git()
* @method Api\GitData gitData()
* @method Api\Gists gist()
* @method Api\Gists gists()
* @method Api\Issue issue()
* @method Api\Issue issues()
* @method Api\Markdown markdown()
* @method Api\Organization organization()
* @method Api\Organization organizations()
* @method Api\PullRequest pr()
* @method Api\PullRequest pullRequest()
* @method Api\PullRequest pullRequests()
* @method Api\Repo repo()
* @method Api\Repo repos()
* @method Api\Repo repository()
* @method Api\Repo repositories()
* @method Api\Organization team()
* @method Api\Organization teams()
* @method Api\User user()
* @method Api\User users()
* @method Api\Authorizations authorization()
* @method Api\Authorizations authorizations()
* @method Api\Meta meta()
*
* @author Joseph Bielawski <[email protected]>
*
* Website: http://github.com/KnpLabs/php-github-api
Expand Down Expand Up @@ -84,6 +112,7 @@ public function api($name)
switch ($name) {
case 'me':
case 'current_user':
case 'currentUser':
$api = new Api\CurrentUser($this);
break;

Expand All @@ -94,6 +123,7 @@ public function api($name)

case 'git':
case 'git_data':
case 'gitData':
$api = new Api\GitData($this);
break;

Expand All @@ -117,7 +147,9 @@ public function api($name)
break;

case 'pr':
case 'pullRequest':
case 'pull_request':
case 'pullRequests':
case 'pull_requests':
$api = new Api\PullRequest($this);
break;
Expand Down Expand Up @@ -274,4 +306,15 @@ public function getSupportedApiVersions()
{
return array('v3', 'beta');
}

/**
* @param string $name
*
* @return ApiInterface
*
* @throws InvalidArgumentException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should throw a BadMethodCallException instead for __call when calling the wrong method (you should catch the InvalidArgumentException and throw another exception)

*/
public function __call($name, $args) {
return $this->api($name);
}
}