Skip to content

Commit 6ceeb55

Browse files
committed
changes based on @acrobat's suggestions
1 parent 6ecdb0a commit 6ceeb55

File tree

1 file changed

+35
-22
lines changed

1 file changed

+35
-22
lines changed

lib/Github/Api/Organization/Teams.php

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
/**
99
* @link http://developer.github.com/v3/orgs/teams/
10-
*
1110
* @author Joseph Bielawski <stloyd@gmail.com>
1211
*/
1312
class Teams extends AbstractApi
@@ -37,11 +36,13 @@ public function create($organization, array $params)
3736
*/
3837
public function show($team, $organization = null)
3938
{
40-
if ($organization) {
41-
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
39+
if (null === $organization) {
40+
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);
41+
42+
return $this->get('/teams/'.rawurlencode($team));
4243
}
4344

44-
return $this->get('/teams/'.rawurlencode($team));
45+
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
4546
}
4647

4748
/**
@@ -56,71 +57,83 @@ public function update($team, array $params, $organization = null)
5657
$params['permission'] = 'pull';
5758
}
5859

59-
if ($organization) {
60-
return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params);
60+
if (null === $organization) {
61+
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);
62+
63+
return $this->patch('/teams/'.rawurlencode($team), $params);
6164
}
6265

63-
return $this->patch('/teams/'.rawurlencode($team), $params);
66+
return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params);
6467
}
6568

6669
/**
6770
* @link https://developer.github.com/v3/teams/#delete-team
6871
*/
6972
public function remove($team, $organization = null)
7073
{
71-
if ($organization) {
72-
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
74+
if (null === $organization) {
75+
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);
76+
77+
return $this->delete('/teams/'.rawurlencode($team));
7378
}
7479

75-
return $this->delete('/teams/'.rawurlencode($team));
80+
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
7681
}
7782

7883
/**
7984
* @link https://developer.github.com/v3/teams/members/#list-team-members
8085
*/
8186
public function members($team, $organization = null)
8287
{
83-
if ($organization) {
84-
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members');
88+
if (null === $organization) {
89+
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);
90+
91+
return $this->get('/teams/'.rawurlencode($team).'/members');
8592
}
8693

87-
return $this->get('/teams/'.rawurlencode($team).'/members');
94+
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members');
8895
}
8996

9097
/**
9198
* @link https://developer.github.com/v3/teams/members/#get-team-membership
9299
*/
93100
public function check($team, $username, $organization = null)
94101
{
95-
if ($organization) {
96-
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
102+
if (null === $organization) {
103+
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);
104+
105+
return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
97106
}
98107

99-
return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
108+
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
100109
}
101110

102111
/**
103112
* @link https://developer.github.com/v3/teams/members/#add-or-update-team-membership
104113
*/
105114
public function addMember($team, $username, $organization = null)
106115
{
107-
if ($organization) {
108-
return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
116+
if (null === $organization) {
117+
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);
118+
119+
return $this->put('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
109120
}
110121

111-
return $this->put('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
122+
return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
112123
}
113124

114125
/**
115126
* @link https://developer.github.com/v3/teams/members/#remove-team-membership
116127
*/
117128
public function removeMember($team, $username, $organization = null)
118129
{
119-
if ($organization) {
120-
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
130+
if (null === $organization) {
131+
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);
132+
133+
return $this->delete('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
121134
}
122135

123-
return $this->delete('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
136+
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
124137
}
125138

126139
public function repositories($team)

0 commit comments

Comments
 (0)