Repository navigation
Expand file tree
/
Copy pathTeam.php
More file actions
172 lines (138 loc) · 3.4 KB
/
Copy pathTeam.php
File metadata and controls
172 lines (138 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
namespace Github\Model;
class Team extends AbstractModel
{
protected static $_properties = array(
'id',
'org',
'url',
'name',
'permission',
'members_count',
'repos_count',
'repositories_url',
'members_url'
);
public static function factory(Owner $org, $id)
{
return new Team($org, $id);
}
public static function fromArray(Owner $org, array $data)
{
$team = Team::factory($org, $data['id']);
return $team->hydrate($data);
}
public function __construct(Owner $org, $id)
{
$this->org = $org;
$this->id = $id;
}
public function show()
{
$data = $this->api('organization')->teams()->show(
$this->id
);
return Team::fromArray($this->org, $data);
}
public function update(array $params)
{
$data = $this-api('organization')->teams()->update(
$this->id,
$params
);
return Team::fromArray($this->org, $data);
}
public function remove()
{
$this->api('organization')->teams()->remove(
$this->id
);
return true;
}
public function members()
{
$data = $this->api('organization')->teams()->members(
$this->id
);
$members = array();
foreach ($data as $member) {
$members[] = User::fromArray($member);
}
return $member;
}
public function check($login)
{
try {
$this->api('organization')->teams()->check(
$this->id,
$login
);
return true;
} catch (\Exception $e) {
return false;
}
}
public function addMember($login)
{
$this->api('organization')->teams()->addMember(
$this->id,
$login
);
return true;
}
public function removeMember($login)
{
$this->api('organization')->teams()->removeMember(
$this->id,
$login
);
return true;
}
public function repositories()
{
$data = $this->api('organization')->teams()->repositories(
$this->id
);
$repos = array();
foreach ($data as $repo) {
$repos[] = Repo::fromArray($repo);
}
return $repos;
}
public function repository($repository)
{
if ($repository instanceof Repo) {
$repository = $repository->name;
}
$data = $this->api('organization')->teams()->repository(
$this->id,
$this->org->login,
$repository
);
return Repo::fromArray($data);
}
public function addRepository($repository)
{
if ($repository instanceof Repo) {
$repository = $repository->name;
}
$this->api('organization')->teams()->addRepository(
$this->id,
$this->org->login,
$repository
);
return true;
}
public function removeRepository($repository)
{
if ($repository instanceof Repo) {
$repository = $repository->name;
}
$this->api('organization')->teams()->removeRepository(
$this->id,
$this->org->login,
$repository
);
return true;
}
}