1
|
|
|
<?php |
2
|
|
|
namespace DevBoardLib\GithubObjectApiFacade\Repo; |
3
|
|
|
|
4
|
|
|
use DevBoardLib\GithubApiFacade\Repo\RepoFacade; |
5
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Branch\Converter\GithubBranchConverter; |
6
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Commit\Converter\GithubCommitConverter; |
7
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\CommitStatus\Converter\GithubCommitStatusConverter; |
8
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Issue\Converter\GithubIssueConverter; |
9
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter\GithubMilestoneConverter; |
10
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\PullRequest\Converter\GithubPullRequestConverter; |
11
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Repo\Converter\GithubRepoConverter; |
12
|
|
|
use DevBoardLib\GithubObjectApiFacade\Repo\Tag\Converter\GithubTagConverter; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class SimpleRepoFacade. |
16
|
|
|
*/ |
17
|
|
|
class SimpleRepoFacade implements ObjectRepoFacade |
18
|
|
|
{ |
19
|
|
|
private $repoFacade; |
20
|
|
|
|
21
|
|
|
private $githubRepoConverter; |
22
|
|
|
private $githubBranchConverter; |
23
|
|
|
private $githubTagConverter; |
24
|
|
|
private $githubPullRequestConverter; |
25
|
|
|
private $githubCommitConverter; |
26
|
|
|
private $githubCommitStatusConverter; |
27
|
|
|
|
28
|
|
|
private $githubIssueConverter; |
29
|
|
|
private $githubMilestoneConverter; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* SimpleRepoFacade constructor. |
33
|
|
|
* |
34
|
|
|
* @param $repoFacade |
35
|
|
|
* @param $githubRepoConverter |
36
|
|
|
* @param $githubBranchConverter |
37
|
|
|
* @param $githubTagConverter |
38
|
|
|
* @param $githubPullRequestConverter |
39
|
|
|
* @param $githubCommitConverter |
40
|
|
|
* @param $githubCommitStatusConverter |
41
|
|
|
* @param $githubIssueConverter |
42
|
|
|
* @param $githubMilestoneConverter |
43
|
|
|
*/ |
44
|
|
|
public function __construct( |
45
|
|
|
RepoFacade $repoFacade, |
46
|
|
|
GithubRepoConverter $githubRepoConverter, |
47
|
|
|
GithubBranchConverter $githubBranchConverter, |
48
|
|
|
GithubTagConverter $githubTagConverter, |
49
|
|
|
GithubPullRequestConverter $githubPullRequestConverter, |
50
|
|
|
GithubCommitConverter $githubCommitConverter, |
51
|
|
|
GithubCommitStatusConverter $githubCommitStatusConverter, |
52
|
|
|
GithubIssueConverter $githubIssueConverter, |
53
|
|
|
GithubMilestoneConverter $githubMilestoneConverter |
54
|
|
|
) { |
55
|
|
|
$this->repoFacade = $repoFacade; |
56
|
|
|
$this->githubRepoConverter = $githubRepoConverter; |
57
|
|
|
$this->githubBranchConverter = $githubBranchConverter; |
58
|
|
|
$this->githubTagConverter = $githubTagConverter; |
59
|
|
|
$this->githubPullRequestConverter = $githubPullRequestConverter; |
60
|
|
|
$this->githubCommitConverter = $githubCommitConverter; |
61
|
|
|
$this->githubCommitStatusConverter = $githubCommitStatusConverter; |
62
|
|
|
$this->githubIssueConverter = $githubIssueConverter; |
63
|
|
|
$this->githubMilestoneConverter = $githubMilestoneConverter; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Fetches GithubRepo details. |
68
|
|
|
* |
69
|
|
|
* @return array |
70
|
|
|
*/ |
71
|
|
|
public function fetchDetails() |
72
|
|
|
{ |
73
|
|
|
$rawResult = $this->repoFacade->fetchDetails(); |
74
|
|
|
|
75
|
|
|
return $this->githubRepoConverter->convert($rawResult); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Fetches GithubBranch details. |
80
|
|
|
* |
81
|
|
|
* @param $branchName |
82
|
|
|
* |
83
|
|
|
* @return array |
84
|
|
|
*/ |
85
|
|
|
public function fetchBranch($branchName) |
86
|
|
|
{ |
87
|
|
|
$rawResult = $this->repoFacade->fetchBranch($branchName); |
88
|
|
|
|
89
|
|
|
return $this->githubBranchConverter->convert($rawResult); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return array |
94
|
|
|
*/ |
95
|
|
|
public function fetchAllBranches() |
96
|
|
|
{ |
97
|
|
|
$results = []; |
98
|
|
|
$rawResults = $this->repoFacade->fetchAllBranches(); |
99
|
|
|
|
100
|
|
|
foreach ($rawResults as $rawResult) { |
101
|
|
|
$results[] = $this->githubBranchConverter->convert($rawResult); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
return $results; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return array |
109
|
|
|
*/ |
110
|
|
|
public function fetchAllTags() |
111
|
|
|
{ |
112
|
|
|
$results = []; |
113
|
|
|
$rawResults = $this->repoFacade->fetchAllTags(); |
114
|
|
|
|
115
|
|
|
foreach ($rawResults as $rawResult) { |
116
|
|
|
$results[] = $this->githubTagConverter->convert($rawResult); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
return $results; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Fetches GithubCommit details. |
124
|
|
|
* |
125
|
|
|
* @param $commitSha |
126
|
|
|
* |
127
|
|
|
* @return array |
128
|
|
|
*/ |
129
|
|
|
public function fetchCommit($commitSha) |
130
|
|
|
{ |
131
|
|
|
$rawResult = $this->repoFacade->fetchCommit($commitSha); |
132
|
|
|
|
133
|
|
|
return $this->githubCommitConverter->convert($rawResult); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Fetches GithubCommit status. |
138
|
|
|
* |
139
|
|
|
* @param $commitSha |
140
|
|
|
* |
141
|
|
|
* @return array |
142
|
|
|
*/ |
143
|
|
|
public function fetchCommitStatus($commitSha) |
144
|
|
|
{ |
145
|
|
|
$results = []; |
146
|
|
|
$rawResults = $this->repoFacade->fetchCommitStatus($commitSha); |
147
|
|
|
|
148
|
|
|
foreach ($rawResults['statuses'] as $rawResult) { |
149
|
|
|
$rawResult['sha'] = $commitSha; |
150
|
|
|
$results[] = $this->githubCommitStatusConverter->convert($rawResult); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
return $results; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Fetches list of GithubCommit statuses. |
158
|
|
|
* |
159
|
|
|
* @param $commitSha |
160
|
|
|
* |
161
|
|
|
* @return array |
162
|
|
|
*/ |
163
|
|
|
public function fetchCommitStatuses($commitSha) |
164
|
|
|
{ |
165
|
|
|
$results = []; |
166
|
|
|
$rawResults = $this->repoFacade->fetchCommitStatuses($commitSha); |
167
|
|
|
|
168
|
|
|
foreach ($rawResults as $rawResult) { |
169
|
|
|
$rawResult['sha'] = $commitSha; |
170
|
|
|
$results[] = $this->githubCommitStatusConverter->convert($rawResult); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
return $results; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @return array |
178
|
|
|
*/ |
179
|
|
|
public function fetchAllPullRequests() |
180
|
|
|
{ |
181
|
|
|
$results = []; |
182
|
|
|
$rawResults = $this->repoFacade->fetchAllPullRequests(); |
183
|
|
|
|
184
|
|
|
foreach ($rawResults as $rawResult) { |
185
|
|
|
$results[] = $this->githubPullRequestConverter->convert($rawResult); |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
return $results; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @return array |
193
|
|
|
*/ |
194
|
|
|
public function fetchAllMilestones() |
195
|
|
|
{ |
196
|
|
|
$results = []; |
197
|
|
|
$rawResults = $this->repoFacade->fetchAllMilestones(); |
198
|
|
|
|
199
|
|
|
foreach ($rawResults as $rawResult) { |
200
|
|
|
$results[] = $this->githubMilestoneConverter->convert($rawResult); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
return $results; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @return array |
208
|
|
|
*/ |
209
|
|
|
public function fetchAllIssues() |
210
|
|
|
{ |
211
|
|
|
$results = []; |
212
|
|
|
$rawResults = $this->repoFacade->fetchAllIssues(); |
213
|
|
|
|
214
|
|
|
foreach ($rawResults as $rawResult) { |
215
|
|
|
$results[] = $this->githubIssueConverter->convert($rawResult); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
return $results; |
219
|
|
|
} |
220
|
|
|
} |
221
|
|
|
|