Skip to content

Commit 6777c5d

Browse files
committed
my repositories added
1 parent e78407f commit 6777c5d

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
1313
- API for Repo\Cards
1414
- API for Repo\Columns
1515
- API for Repo\Projects
16+
- API for User\MyRepositories
1617
- Methods in Repo API for frequency and participation
1718

1819
### Changed

lib/Github/Api/User.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,9 @@ public function subscriptions($username)
145145
}
146146

147147
/**
148-
* @deprecated use repos($username, $options) instead
148+
* List public repositories for the specified user.
149149
*
150-
* Get the repositories of a user.
151-
*
152-
* @link http://developer.github.com/v3/repos/
150+
* @link https://developer.github.com/v3/repos/#list-user-repositories
153151
*
154152
* @param string $username the username
155153
* @param string $type role in the repository
@@ -160,24 +158,25 @@ public function subscriptions($username)
160158
*/
161159
public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc')
162160
{
163-
return $this->repos($username, array(
161+
return $this->get('/users/'.rawurldecode($username).'/repos', [
164162
'type' => $type,
165163
'sort' => $sort,
166-
'direction' => $direction
167-
));
164+
'direction' => $direction,
165+
]);
168166
}
169167

170168
/**
171-
* @param null $username
172-
* @param array $options
169+
* List repositories that are accessible to the authenticated user.
170+
*
171+
* @link https://developer.github.com/v3/repos/#list-your-repositories
172+
*
173+
* @param array $params visibility, affiliation, type, sort, direction
173174
*
174175
* @return array list of the user repositories
175176
*/
176-
public function repos($username = null, array $options = array())
177+
public function myRepositories(array $params = [])
177178
{
178-
$url = $username ? '/users/'.rawurldecode($username).'/repos' : '/user/repos';
179-
180-
return $this->get($url, $options);
179+
return $this->get('/user/repos', $params);
181180
}
182181

183182
/**

test/Github/Tests/Api/UserTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ public function shouldGetUserRepositories()
145145
$this->assertEquals($expectedArray, $api->repositories('l3l0'));
146146
}
147147

148+
/**
149+
* @test
150+
*/
151+
public function shouldGetMyRepositories()
152+
{
153+
$expectedArray = [['id' => 1, 'name' => 'l3l0repo']];
154+
155+
$api = $this->getApiMock();
156+
$api->expects($this->once())
157+
->method('get')->with('/user/repos', [])
158+
->will($this->returnValue($expectedArray));
159+
160+
$this->assertEquals($expectedArray, $api->myRepositories());
161+
}
162+
148163
/**
149164
* @test
150165
*/

0 commit comments

Comments
 (0)