1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace tests\DevBoardLib\GithubObjectApiFacade; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class JsonSampleDataProvider. |
7
|
|
|
*/ |
8
|
|
|
class JsonSampleDataProvider |
9
|
|
|
{ |
10
|
|
|
/** Full name of default repo */ |
11
|
|
|
const DEFAULT_REPO = 'devboard/test-hitman'; |
12
|
|
|
/** Branch name of default branch*/ |
13
|
|
|
const DEFAULT_BRANCH = 'master'; |
14
|
|
|
/** Sha for default commit*/ |
15
|
|
|
const DEFAULT_COMMIT_SHA = 'db911bd3a3dd8bb2ad9eccbcb0a396595a51491d'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @return array |
19
|
|
|
*/ |
20
|
|
|
public function getRepos() |
21
|
|
|
{ |
22
|
|
|
return $this->getMyRepositoriesAll(); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param string $fullName |
27
|
|
|
* |
28
|
|
|
* @return mixed |
29
|
|
|
*/ |
30
|
|
|
public function getRepoDetails(string $fullName = self::DEFAULT_REPO) |
31
|
|
|
{ |
32
|
|
|
$content = file_get_contents(__DIR__.'/sample-data/'.$fullName.'/repo-details.json'); |
33
|
|
|
|
34
|
|
|
return json_decode($content, true); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param string $fullName |
39
|
|
|
* @param string $branchName |
40
|
|
|
* |
41
|
|
|
* @return mixed |
42
|
|
|
*/ |
43
|
|
|
public function getBranch(string $fullName = self::DEFAULT_REPO, string $branchName = self::DEFAULT_BRANCH) |
44
|
|
|
{ |
45
|
|
|
$content = file_get_contents(__DIR__.'/sample-data/'.$fullName.'/branch-'.$branchName.'.json'); |
46
|
|
|
|
47
|
|
|
return json_decode($content, true); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param string $fullName |
52
|
|
|
* |
53
|
|
|
* @return mixed |
54
|
|
|
*/ |
55
|
|
|
public function getAllBranches(string $fullName = self::DEFAULT_REPO) |
56
|
|
|
{ |
57
|
|
|
$content = file_get_contents(__DIR__.'/sample-data/'.$fullName.'/branches.json'); |
58
|
|
|
|
59
|
|
|
return json_decode($content, true); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param string $fullName |
64
|
|
|
* |
65
|
|
|
* @return mixed |
66
|
|
|
*/ |
67
|
|
|
public function getAllBranchNames(string $fullName = self::DEFAULT_REPO) |
68
|
|
|
{ |
69
|
|
|
$content = file_get_contents(__DIR__.'/sample-data/'.$fullName.'/branchnames.json'); |
70
|
|
|
|
71
|
|
|
return json_decode($content, true); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param string $fullName |
76
|
|
|
* |
77
|
|
|
* @return mixed |
78
|
|
|
*/ |
79
|
|
|
public function getAllTagNames(string $fullName = self::DEFAULT_REPO) |
80
|
|
|
{ |
81
|
|
|
$content = file_get_contents(__DIR__.'/sample-data/'.$fullName.'/tags.json'); |
82
|
|
|
|
83
|
|
|
return json_decode($content, true); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param string $fullName |
88
|
|
|
* @param string $sha |
89
|
|
|
* |
90
|
|
|
* @return mixed |
91
|
|
|
*/ |
92
|
|
View Code Duplication |
public function getCommit(string $fullName = self::DEFAULT_REPO, string $sha = self::DEFAULT_COMMIT_SHA) |
|
|
|
|
93
|
|
|
{ |
94
|
|
|
$content = file_get_contents( |
95
|
|
|
__DIR__.'/sample-data/'.$fullName.'/commit-'.$sha.'.json' |
96
|
|
|
); |
97
|
|
|
|
98
|
|
|
return json_decode($content, true); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @param string $fullName |
103
|
|
|
* @param string $sha |
104
|
|
|
* |
105
|
|
|
* @return mixed |
106
|
|
|
*/ |
107
|
|
View Code Duplication |
public function getCommitStatus(string $fullName = self::DEFAULT_REPO, string $sha = self::DEFAULT_COMMIT_SHA) |
|
|
|
|
108
|
|
|
{ |
109
|
|
|
$content = file_get_contents( |
110
|
|
|
__DIR__.'/sample-data/'.$fullName.'/commit_status-'.$sha.'.json' |
111
|
|
|
); |
112
|
|
|
|
113
|
|
|
return json_decode($content, true); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param string $fullName |
118
|
|
|
* @param string $sha |
119
|
|
|
* |
120
|
|
|
* @return mixed |
121
|
|
|
*/ |
122
|
|
View Code Duplication |
public function getCommitStatuses(string $fullName = self::DEFAULT_REPO, string $sha = self::DEFAULT_COMMIT_SHA) |
|
|
|
|
123
|
|
|
{ |
124
|
|
|
$content = file_get_contents( |
125
|
|
|
__DIR__.'/sample-data/'.$fullName.'/commit_statuses-'.$sha.'.json' |
126
|
|
|
); |
127
|
|
|
|
128
|
|
|
return json_decode($content, true); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param string $fullName |
133
|
|
|
* |
134
|
|
|
* @return mixed |
135
|
|
|
*/ |
136
|
|
|
public function getAllPullRequests(string $fullName = self::DEFAULT_REPO) |
137
|
|
|
{ |
138
|
|
|
$content = file_get_contents(__DIR__.'/sample-data/'.$fullName.'/pullrequests.json'); |
139
|
|
|
|
140
|
|
|
return json_decode($content, true); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @param string $fullName |
145
|
|
|
* |
146
|
|
|
* @return mixed |
147
|
|
|
*/ |
148
|
|
|
public function getAllMilestones(string $fullName = self::DEFAULT_REPO) |
149
|
|
|
{ |
150
|
|
|
$content = file_get_contents(__DIR__.'/sample-data/'.$fullName.'/milestones.json'); |
151
|
|
|
|
152
|
|
|
return json_decode($content, true); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param string $fullName |
157
|
|
|
* |
158
|
|
|
* @return mixed |
159
|
|
|
*/ |
160
|
|
|
public function getAllIssues(string $fullName = self::DEFAULT_REPO) |
161
|
|
|
{ |
162
|
|
|
$content = file_get_contents(__DIR__.'/sample-data/'.$fullName.'/issues.json'); |
163
|
|
|
|
164
|
|
|
return json_decode($content, true); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @return mixed |
169
|
|
|
*/ |
170
|
|
|
public function getMyRepositoriesAll() |
171
|
|
|
{ |
172
|
|
|
$content = file_get_contents(__DIR__.'/sample-data/me/repositories/all.json'); |
173
|
|
|
|
174
|
|
|
return json_decode($content, true); |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.