Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions doc/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ $user = $client->api('user')->show('KnpLabs');

Returns an array of information about the user.


You can also use the User ID, but it will use an undocumented Github API

```php
$user = $client->api('user')->showById(202732);
```

### Update user information

> Requires [authentication](security.md).
Expand Down
15 changes: 15 additions & 0 deletions lib/Github/Api/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ public function show($username)
return $this->get('/users/'.rawurlencode($username));
}

/**
* Get extended information about a user by its id.
* Note: at time of writing this is an undocumented feature but GitHub support have advised that it can be relied on.
*
* @link http://developer.github.com/v3/users/
*
* @param int $id the id of the user to show
*
* @return array information about the user
*/
public function showById($id)
{
return $this->get('/user/'.$id);
}

/**
* Get extended information about a user by its username.
*
Expand Down
16 changes: 16 additions & 0 deletions test/Github/Tests/Api/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ public function shouldShowUser()
$this->assertEquals($expectedArray, $api->show('l3l0'));
}

/**
* @test
*/
public function shouldShowByIdUser()
{
$expectedArray = ['id' => 1, 'username' => 'l3l0'];

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/user/1')
->will($this->returnValue($expectedArray));

$this->assertEquals($expectedArray, $api->showById(1));
}

/**
* @test
*/
Expand Down