1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DevBoardLib\GithubCore\Repo; |
4
|
|
|
|
5
|
|
|
use DateTime; |
6
|
|
|
use DevBoardLib\GithubCore\User\GithubUser; |
7
|
|
|
use DevBoardLib\GithubCore\User\GithubUserId; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class GithubRepoSource. |
11
|
|
|
*/ |
12
|
|
|
class GithubRepoSource implements GithubRepo, GithubRepoPermissonsInterface |
13
|
|
|
{ |
14
|
|
|
/** @var GithubRepoId */ |
15
|
|
|
private $id; |
16
|
|
|
/** @var GithubUser */ |
17
|
|
|
private $ownerUser; |
18
|
|
|
/** @var string */ |
19
|
|
|
private $owner; |
20
|
|
|
/** @var string */ |
21
|
|
|
private $name; |
22
|
|
|
/** @var string */ |
23
|
|
|
private $fullName; |
24
|
|
|
/** @var string */ |
25
|
|
|
private $htmlUrl; |
26
|
|
|
/** @var string */ |
27
|
|
|
private $description; |
28
|
|
|
/** @var int */ |
29
|
|
|
private $fork; |
30
|
|
|
/** @var string */ |
31
|
|
|
private $defaultBranch; |
32
|
|
|
/** @var int */ |
33
|
|
|
private $private; |
34
|
|
|
/** @var string */ |
35
|
|
|
private $gitUrl; |
36
|
|
|
/** @var string */ |
37
|
|
|
private $sshUrl; |
38
|
|
|
/** @var GithubRepoPermissions */ |
39
|
|
|
private $permissions; |
40
|
|
|
/** @var DateTime */ |
41
|
|
|
private $githubCreatedAt; |
42
|
|
|
/** @var DateTime */ |
43
|
|
|
private $githubUpdatedAt; |
44
|
|
|
/** @var DateTime */ |
45
|
|
|
private $githubPushedAt; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* GithubRepoSource constructor. |
49
|
|
|
* |
50
|
|
|
* @param GithubRepoId $id |
51
|
|
|
* @param GithubUser $ownerUser |
52
|
|
|
* @param string $owner |
53
|
|
|
* @param string $name |
54
|
|
|
* @param string $fullName |
55
|
|
|
* @param string $htmlUrl |
56
|
|
|
* @param string $description |
57
|
|
|
* @param bool $fork |
58
|
|
|
* @param string $defaultBranch |
59
|
|
|
* @param bool $private |
60
|
|
|
* @param string $gitUrl |
61
|
|
|
* @param string $sshUrl |
62
|
|
|
* @param GithubRepoPermissions $permissions |
63
|
|
|
* @param DateTime $githubCreatedAt |
64
|
|
|
* @param DateTime $githubUpdatedAt |
65
|
|
|
* @param DateTime $githubPushedAt |
66
|
|
|
* |
67
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveParameterList) |
68
|
|
|
*/ |
69
|
|
|
public function __construct( |
70
|
|
|
GithubRepoId $id, |
71
|
|
|
GithubUser $ownerUser, |
72
|
|
|
$owner, |
73
|
|
|
$name, |
74
|
|
|
$fullName, |
75
|
|
|
$htmlUrl, |
76
|
|
|
$description, |
77
|
|
|
$fork, |
78
|
|
|
$defaultBranch, |
79
|
|
|
$private, |
80
|
|
|
$gitUrl, |
81
|
|
|
$sshUrl, |
82
|
|
|
GithubRepoPermissions $permissions = null, |
83
|
|
|
DateTime $githubCreatedAt, |
84
|
|
|
DateTime $githubUpdatedAt, |
85
|
|
|
DateTime $githubPushedAt |
86
|
|
|
) { |
87
|
|
|
$this->id = $id; |
88
|
|
|
$this->ownerUser = $ownerUser; |
89
|
|
|
$this->owner = $owner; |
90
|
|
|
$this->name = $name; |
91
|
|
|
$this->fullName = $fullName; |
92
|
|
|
$this->htmlUrl = $htmlUrl; |
93
|
|
|
$this->description = $description; |
94
|
|
|
$this->fork = $fork; |
|
|
|
|
95
|
|
|
$this->defaultBranch = $defaultBranch; |
96
|
|
|
$this->private = $private; |
|
|
|
|
97
|
|
|
$this->gitUrl = $gitUrl; |
98
|
|
|
$this->sshUrl = $sshUrl; |
99
|
|
|
$this->permissions = $permissions; |
100
|
|
|
$this->githubCreatedAt = $githubCreatedAt; |
101
|
|
|
$this->githubUpdatedAt = $githubUpdatedAt; |
102
|
|
|
$this->githubPushedAt = $githubPushedAt; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return GithubRepoId |
107
|
|
|
*/ |
108
|
|
|
public function getId() |
109
|
|
|
{ |
110
|
|
|
return $this->id; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return GithubUserId |
115
|
|
|
*/ |
116
|
|
|
public function getOwnerUserId() |
117
|
|
|
{ |
118
|
|
|
return $this->ownerUser->getGithubUserId(); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return GithubUser |
123
|
|
|
*/ |
124
|
|
|
public function getOwnerUser() |
125
|
|
|
{ |
126
|
|
|
return $this->ownerUser; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return string |
131
|
|
|
*/ |
132
|
|
|
public function getOwner() |
133
|
|
|
{ |
134
|
|
|
return $this->owner; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return string |
139
|
|
|
*/ |
140
|
|
|
public function getName() |
141
|
|
|
{ |
142
|
|
|
return $this->name; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
|
|
public function getFullName() |
149
|
|
|
{ |
150
|
|
|
return $this->fullName; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return string |
155
|
|
|
*/ |
156
|
|
|
public function getHtmlUrl() |
157
|
|
|
{ |
158
|
|
|
return $this->htmlUrl; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @return string |
163
|
|
|
*/ |
164
|
|
|
public function getDescription() |
165
|
|
|
{ |
166
|
|
|
return $this->description; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return int |
171
|
|
|
*/ |
172
|
|
|
public function isFork() |
173
|
|
|
{ |
174
|
|
|
return $this->fork; |
|
|
|
|
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return string |
179
|
|
|
*/ |
180
|
|
|
public function getDefaultBranch() |
181
|
|
|
{ |
182
|
|
|
return $this->defaultBranch; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return int |
187
|
|
|
*/ |
188
|
|
|
public function isPrivate() |
189
|
|
|
{ |
190
|
|
|
return $this->private; |
|
|
|
|
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @return string |
195
|
|
|
*/ |
196
|
|
|
public function getGitUrl() |
197
|
|
|
{ |
198
|
|
|
return $this->gitUrl; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return string |
203
|
|
|
*/ |
204
|
|
|
public function getSshUrl() |
205
|
|
|
{ |
206
|
|
|
return $this->sshUrl; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @return bool |
211
|
|
|
*/ |
212
|
|
|
public function isAdmin() |
213
|
|
|
{ |
214
|
|
|
return $this->permissions->isAdmin(); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return bool |
219
|
|
|
*/ |
220
|
|
|
public function isPushAllowed() |
221
|
|
|
{ |
222
|
|
|
return $this->permissions->isPushAllowed(); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @return bool |
227
|
|
|
*/ |
228
|
|
|
public function isReadAllowed() |
229
|
|
|
{ |
230
|
|
|
return $this->permissions->isReadAllowed(); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* @return DateTime |
235
|
|
|
*/ |
236
|
|
|
public function getGithubCreatedAt() |
237
|
|
|
{ |
238
|
|
|
return $this->githubCreatedAt; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* @return DateTime |
243
|
|
|
*/ |
244
|
|
|
public function getGithubUpdatedAt() |
245
|
|
|
{ |
246
|
|
|
return $this->githubUpdatedAt; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @return DateTime |
251
|
|
|
*/ |
252
|
|
|
public function getGithubPushedAt() |
253
|
|
|
{ |
254
|
|
|
return $this->githubPushedAt; |
255
|
|
|
} |
256
|
|
|
} |
257
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.