Skip to content

Added 'user/repos' missing endpoint #472

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 3 commits into from
Dec 11, 2016
Merged
Changes from 2 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
17 changes: 16 additions & 1 deletion lib/Github/Api/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public function subscriptions($username)
}

/**
* @deprecated use repos($username, $options) instead
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should remove this function. It is okey, we will soon release a new major version.

Please make sure to add this in the changelog.

*
* Get the repositories of a user.
*
* @link http://developer.github.com/v3/repos/
Expand All @@ -158,13 +160,26 @@ public function subscriptions($username)
*/
public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc')
{
return $this->get('/users/'.rawurlencode($username).'/repos', array(
return $this->repos($username, array(
'type' => $type,
'sort' => $sort,
'direction' => $direction
));
}

/**
* @param null $username
* @param array $options
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should explain the valid array keys.

Copy link
Contributor

Choose a reason for hiding this comment

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

or better add in-code assert

*
* @return array list of the user repositories
*/
public function repos($username = null, array $options = array())
Copy link
Contributor

Choose a reason for hiding this comment

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

you should use short array syntax []

{
$url = $username ? '/users/'.rawurldecode($username).'/repos' : '/user/repos';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm. This seams like two functions mixed in one method. I'm not 100% convinced. It may be better to "repos()" and "myRepos()" (but with better naming)

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no other API endpoint that we are using an optional username. I recommend using two functions.


return $this->get($url, $options);
}

/**
* Get the public gists for a user.
*
Expand Down