@@ -13,253 +13,253 @@ |
||
13 | 13 | class Gists extends AbstractReceiver |
14 | 14 | { |
15 | 15 | |
16 | - /** Available sub-Receiver */ |
|
17 | - const COMMENTS = 'Comments'; |
|
16 | + /** Available sub-Receiver */ |
|
17 | + const COMMENTS = 'Comments'; |
|
18 | 18 | |
19 | - /** |
|
20 | - * List a user's gists |
|
21 | - * |
|
22 | - * @link https://developer.github.com/v3/gists/#list-a-users-gists |
|
23 | - * |
|
24 | - * @param string $username |
|
25 | - * @param string $since |
|
26 | - * |
|
27 | - * @return array |
|
28 | - */ |
|
29 | - public function listGists(string $username = null, string $since = '1970-01-01'): array |
|
30 | - { |
|
31 | - $url = '/gists'; |
|
32 | - if (null !== $username) { |
|
33 | - $url = '/users/:username/gists'; |
|
34 | - } |
|
19 | + /** |
|
20 | + * List a user's gists |
|
21 | + * |
|
22 | + * @link https://developer.github.com/v3/gists/#list-a-users-gists |
|
23 | + * |
|
24 | + * @param string $username |
|
25 | + * @param string $since |
|
26 | + * |
|
27 | + * @return array |
|
28 | + */ |
|
29 | + public function listGists(string $username = null, string $since = '1970-01-01'): array |
|
30 | + { |
|
31 | + $url = '/gists'; |
|
32 | + if (null !== $username) { |
|
33 | + $url = '/users/:username/gists'; |
|
34 | + } |
|
35 | 35 | |
36 | - return $this->getApi()->request($this->getApi()->sprintf(':url?:arg', $url, $username, |
|
37 | - http_build_query(['since' => (new DateTime($since))->format(DateTime::ATOM)]))); |
|
38 | - } |
|
36 | + return $this->getApi()->request($this->getApi()->sprintf(':url?:arg', $url, $username, |
|
37 | + http_build_query(['since' => (new DateTime($since))->format(DateTime::ATOM)]))); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * List all public gists: |
|
42 | - * |
|
43 | - * @link https://developer.github.com/v3/gists/#list-all-public-gists |
|
44 | - * |
|
45 | - * @param string $since |
|
46 | - * |
|
47 | - * @return array |
|
48 | - */ |
|
49 | - public function listPublicGists(string $since = '1970-01-01'): array |
|
50 | - { |
|
51 | - return $this->getApi()->request($this->getApi()->sprintf('/gists/public?:arg', |
|
52 | - http_build_query(['since' => (new DateTime($since))->format(DateTime::ATOM)]))); |
|
53 | - } |
|
40 | + /** |
|
41 | + * List all public gists: |
|
42 | + * |
|
43 | + * @link https://developer.github.com/v3/gists/#list-all-public-gists |
|
44 | + * |
|
45 | + * @param string $since |
|
46 | + * |
|
47 | + * @return array |
|
48 | + */ |
|
49 | + public function listPublicGists(string $since = '1970-01-01'): array |
|
50 | + { |
|
51 | + return $this->getApi()->request($this->getApi()->sprintf('/gists/public?:arg', |
|
52 | + http_build_query(['since' => (new DateTime($since))->format(DateTime::ATOM)]))); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * List the authenticated user’s starred gists |
|
57 | - * |
|
58 | - * @link https://developer.github.com/v3/gists/#list-starred-gists |
|
59 | - * |
|
60 | - * @param string $since |
|
61 | - * |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - public function listUsersStarredGists(string $since = '1970-01-01'): array |
|
65 | - { |
|
66 | - return $this->getApi()->request($this->getApi()->sprintf('/gists/starred?:arg', |
|
67 | - http_build_query(['since' => (new DateTime($since))->format(DateTime::ATOM)]))); |
|
68 | - } |
|
55 | + /** |
|
56 | + * List the authenticated user’s starred gists |
|
57 | + * |
|
58 | + * @link https://developer.github.com/v3/gists/#list-starred-gists |
|
59 | + * |
|
60 | + * @param string $since |
|
61 | + * |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + public function listUsersStarredGists(string $since = '1970-01-01'): array |
|
65 | + { |
|
66 | + return $this->getApi()->request($this->getApi()->sprintf('/gists/starred?:arg', |
|
67 | + http_build_query(['since' => (new DateTime($since))->format(DateTime::ATOM)]))); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Get a single gist |
|
72 | - * |
|
73 | - * @link https://developer.github.com/v3/gists/#get-a-single-gist |
|
74 | - * |
|
75 | - * @param int $id |
|
76 | - * |
|
77 | - * @return array |
|
78 | - */ |
|
79 | - public function getGist(int $id): array |
|
80 | - { |
|
81 | - return $this->getApi()->request($this->getApi()->sprintf('/gists/:id', $id)); |
|
82 | - } |
|
70 | + /** |
|
71 | + * Get a single gist |
|
72 | + * |
|
73 | + * @link https://developer.github.com/v3/gists/#get-a-single-gist |
|
74 | + * |
|
75 | + * @param int $id |
|
76 | + * |
|
77 | + * @return array |
|
78 | + */ |
|
79 | + public function getGist(int $id): array |
|
80 | + { |
|
81 | + return $this->getApi()->request($this->getApi()->sprintf('/gists/:id', $id)); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Get a specific revision of a gist |
|
86 | - * |
|
87 | - * @link https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist |
|
88 | - * |
|
89 | - * @param string $id |
|
90 | - * @param string $sha |
|
91 | - * |
|
92 | - * @return array |
|
93 | - * @throws \Exception |
|
94 | - */ |
|
95 | - public function getGistRevision(string $id, string $sha): array |
|
96 | - { |
|
97 | - return $this->getApi()->request($this->getApi()->sprintf('/gists/:id/:sha', $id, $sha)); |
|
98 | - } |
|
84 | + /** |
|
85 | + * Get a specific revision of a gist |
|
86 | + * |
|
87 | + * @link https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist |
|
88 | + * |
|
89 | + * @param string $id |
|
90 | + * @param string $sha |
|
91 | + * |
|
92 | + * @return array |
|
93 | + * @throws \Exception |
|
94 | + */ |
|
95 | + public function getGistRevision(string $id, string $sha): array |
|
96 | + { |
|
97 | + return $this->getApi()->request($this->getApi()->sprintf('/gists/:id/:sha', $id, $sha)); |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * Create a gist |
|
102 | - * |
|
103 | - * @link https://developer.github.com/v3/gists/#create-a-gist |
|
104 | - * |
|
105 | - * @param string $files |
|
106 | - * @param string $description |
|
107 | - * @param bool $public |
|
108 | - * |
|
109 | - * @return array |
|
110 | - */ |
|
111 | - public function createGist(string $files, string $description = null, bool $public = false): array |
|
112 | - { |
|
113 | - return $this->getApi()->request($this->getApi()->sprintf('/gists'), Request::METHOD_POST, [ |
|
114 | - 'files' => $files, |
|
115 | - 'description' => $description, |
|
116 | - 'public' => $public |
|
117 | - ]); |
|
118 | - } |
|
100 | + /** |
|
101 | + * Create a gist |
|
102 | + * |
|
103 | + * @link https://developer.github.com/v3/gists/#create-a-gist |
|
104 | + * |
|
105 | + * @param string $files |
|
106 | + * @param string $description |
|
107 | + * @param bool $public |
|
108 | + * |
|
109 | + * @return array |
|
110 | + */ |
|
111 | + public function createGist(string $files, string $description = null, bool $public = false): array |
|
112 | + { |
|
113 | + return $this->getApi()->request($this->getApi()->sprintf('/gists'), Request::METHOD_POST, [ |
|
114 | + 'files' => $files, |
|
115 | + 'description' => $description, |
|
116 | + 'public' => $public |
|
117 | + ]); |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Edit a gist |
|
122 | - * |
|
123 | - * @link https://developer.github.com/v3/gists/#edit-a-gist |
|
124 | - * |
|
125 | - * @param int $id |
|
126 | - * @param string $description |
|
127 | - * @param string $files |
|
128 | - * @param string $content |
|
129 | - * @param string $filename |
|
130 | - * |
|
131 | - * @return array |
|
132 | - */ |
|
133 | - public function editGist(int $id, string $description = '', string $files = '{}', string $content = '', |
|
134 | - string $filename = ''): array |
|
135 | - { |
|
136 | - return $this->getApi()->request($this->getApi()->sprintf('/gists/:id', $id), Request::METHOD_PATCH, [ |
|
137 | - 'description' => $description, |
|
138 | - 'files' => $files, |
|
139 | - 'content' => $content, |
|
140 | - 'filename' => $filename |
|
141 | - ]); |
|
142 | - } |
|
120 | + /** |
|
121 | + * Edit a gist |
|
122 | + * |
|
123 | + * @link https://developer.github.com/v3/gists/#edit-a-gist |
|
124 | + * |
|
125 | + * @param int $id |
|
126 | + * @param string $description |
|
127 | + * @param string $files |
|
128 | + * @param string $content |
|
129 | + * @param string $filename |
|
130 | + * |
|
131 | + * @return array |
|
132 | + */ |
|
133 | + public function editGist(int $id, string $description = '', string $files = '{}', string $content = '', |
|
134 | + string $filename = ''): array |
|
135 | + { |
|
136 | + return $this->getApi()->request($this->getApi()->sprintf('/gists/:id', $id), Request::METHOD_PATCH, [ |
|
137 | + 'description' => $description, |
|
138 | + 'files' => $files, |
|
139 | + 'content' => $content, |
|
140 | + 'filename' => $filename |
|
141 | + ]); |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * List gist commits |
|
146 | - * |
|
147 | - * @link https://developer.github.com/v3/gists/#list-gist-commits |
|
148 | - * |
|
149 | - * @param int $id |
|
150 | - * |
|
151 | - * @return array |
|
152 | - */ |
|
153 | - public function listGistsCommits(int $id): array |
|
154 | - { |
|
155 | - return $this->getApi()->request($this->getApi()->sprintf('/gists/:id/commits', $id)); |
|
156 | - } |
|
144 | + /** |
|
145 | + * List gist commits |
|
146 | + * |
|
147 | + * @link https://developer.github.com/v3/gists/#list-gist-commits |
|
148 | + * |
|
149 | + * @param int $id |
|
150 | + * |
|
151 | + * @return array |
|
152 | + */ |
|
153 | + public function listGistsCommits(int $id): array |
|
154 | + { |
|
155 | + return $this->getApi()->request($this->getApi()->sprintf('/gists/:id/commits', $id)); |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * Star a gist |
|
160 | - * |
|
161 | - * @link https://developer.github.com/v3/gists/#star-a-gist |
|
162 | - * |
|
163 | - * @param int $id |
|
164 | - * |
|
165 | - * @return bool |
|
166 | - */ |
|
167 | - public function starGist(int $id): bool |
|
168 | - { |
|
169 | - $this->getApi()->request($this->getApi()->sprintf('/gists/:id/star', $id), Request::METHOD_PUT); |
|
158 | + /** |
|
159 | + * Star a gist |
|
160 | + * |
|
161 | + * @link https://developer.github.com/v3/gists/#star-a-gist |
|
162 | + * |
|
163 | + * @param int $id |
|
164 | + * |
|
165 | + * @return bool |
|
166 | + */ |
|
167 | + public function starGist(int $id): bool |
|
168 | + { |
|
169 | + $this->getApi()->request($this->getApi()->sprintf('/gists/:id/star', $id), Request::METHOD_PUT); |
|
170 | 170 | |
171 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
172 | - return true; |
|
173 | - } |
|
171 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
172 | + return true; |
|
173 | + } |
|
174 | 174 | |
175 | - return false; |
|
176 | - } |
|
175 | + return false; |
|
176 | + } |
|
177 | 177 | |
178 | - /** |
|
179 | - * Unstar a gist |
|
180 | - * |
|
181 | - * @link https://developer.github.com/v3/gists/#unstar-a-gist |
|
182 | - * |
|
183 | - * @param int $id |
|
184 | - * |
|
185 | - * @return bool |
|
186 | - */ |
|
187 | - public function unStarGist(int $id): bool |
|
188 | - { |
|
189 | - $this->getApi()->request($this->getApi()->sprintf('/gists/:id/star', $id), Request::METHOD_DELETE); |
|
178 | + /** |
|
179 | + * Unstar a gist |
|
180 | + * |
|
181 | + * @link https://developer.github.com/v3/gists/#unstar-a-gist |
|
182 | + * |
|
183 | + * @param int $id |
|
184 | + * |
|
185 | + * @return bool |
|
186 | + */ |
|
187 | + public function unStarGist(int $id): bool |
|
188 | + { |
|
189 | + $this->getApi()->request($this->getApi()->sprintf('/gists/:id/star', $id), Request::METHOD_DELETE); |
|
190 | 190 | |
191 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
192 | - return true; |
|
193 | - } |
|
191 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
192 | + return true; |
|
193 | + } |
|
194 | 194 | |
195 | - return false; |
|
196 | - } |
|
195 | + return false; |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * Check if a gist is starred |
|
200 | - * |
|
201 | - * @link https://developer.github.com/v3/gists/#check-if-a-gist-is-starred |
|
202 | - * |
|
203 | - * @param int $id |
|
204 | - * |
|
205 | - * @return bool |
|
206 | - */ |
|
207 | - public function checkGistIsStarred(int $id): bool |
|
208 | - { |
|
209 | - $this->getApi()->request($this->getApi()->sprintf('/gists/:id/star', $id)); |
|
198 | + /** |
|
199 | + * Check if a gist is starred |
|
200 | + * |
|
201 | + * @link https://developer.github.com/v3/gists/#check-if-a-gist-is-starred |
|
202 | + * |
|
203 | + * @param int $id |
|
204 | + * |
|
205 | + * @return bool |
|
206 | + */ |
|
207 | + public function checkGistIsStarred(int $id): bool |
|
208 | + { |
|
209 | + $this->getApi()->request($this->getApi()->sprintf('/gists/:id/star', $id)); |
|
210 | 210 | |
211 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
212 | - return true; |
|
213 | - } |
|
211 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
212 | + return true; |
|
213 | + } |
|
214 | 214 | |
215 | - return false; |
|
216 | - } |
|
215 | + return false; |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
219 | - * Fork a gist |
|
220 | - * |
|
221 | - * @link https://developer.github.com/v3/gists/#fork-a-gist |
|
222 | - * |
|
223 | - * @param int $id |
|
224 | - * |
|
225 | - * @return array |
|
226 | - */ |
|
227 | - public function forkGist(int $id): array |
|
228 | - { |
|
229 | - return $this->getApi()->request($this->getApi()->sprintf('/gists/:id/forks', $id), Request::METHOD_POST); |
|
230 | - } |
|
218 | + /** |
|
219 | + * Fork a gist |
|
220 | + * |
|
221 | + * @link https://developer.github.com/v3/gists/#fork-a-gist |
|
222 | + * |
|
223 | + * @param int $id |
|
224 | + * |
|
225 | + * @return array |
|
226 | + */ |
|
227 | + public function forkGist(int $id): array |
|
228 | + { |
|
229 | + return $this->getApi()->request($this->getApi()->sprintf('/gists/:id/forks', $id), Request::METHOD_POST); |
|
230 | + } |
|
231 | 231 | |
232 | - /** |
|
233 | - * List gist forks |
|
234 | - * |
|
235 | - * @link https://developer.github.com/v3/gists/#list-gist-forks |
|
236 | - * |
|
237 | - * @param int $id |
|
238 | - * |
|
239 | - * @return array |
|
240 | - */ |
|
241 | - public function listGistForks(int $id): array |
|
242 | - { |
|
243 | - return $this->getApi()->request($this->getApi()->sprintf('/gists/:id/forks', $id)); |
|
244 | - } |
|
232 | + /** |
|
233 | + * List gist forks |
|
234 | + * |
|
235 | + * @link https://developer.github.com/v3/gists/#list-gist-forks |
|
236 | + * |
|
237 | + * @param int $id |
|
238 | + * |
|
239 | + * @return array |
|
240 | + */ |
|
241 | + public function listGistForks(int $id): array |
|
242 | + { |
|
243 | + return $this->getApi()->request($this->getApi()->sprintf('/gists/:id/forks', $id)); |
|
244 | + } |
|
245 | 245 | |
246 | - /** |
|
247 | - * Delete a gist |
|
248 | - * |
|
249 | - * @link https://developer.github.com/v3/gists/#delete-a-gist |
|
250 | - * |
|
251 | - * @param int $id |
|
252 | - * |
|
253 | - * @return bool |
|
254 | - */ |
|
255 | - public function deleteGist(int $id): bool |
|
256 | - { |
|
257 | - $this->getApi()->request($this->getApi()->sprintf('/gists/:id', $id), Request::METHOD_DELETE); |
|
246 | + /** |
|
247 | + * Delete a gist |
|
248 | + * |
|
249 | + * @link https://developer.github.com/v3/gists/#delete-a-gist |
|
250 | + * |
|
251 | + * @param int $id |
|
252 | + * |
|
253 | + * @return bool |
|
254 | + */ |
|
255 | + public function deleteGist(int $id): bool |
|
256 | + { |
|
257 | + $this->getApi()->request($this->getApi()->sprintf('/gists/:id', $id), Request::METHOD_DELETE); |
|
258 | 258 | |
259 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
260 | - return true; |
|
261 | - } |
|
259 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
260 | + return true; |
|
261 | + } |
|
262 | 262 | |
263 | - return false; |
|
264 | - } |
|
263 | + return false; |
|
264 | + } |
|
265 | 265 | } |
266 | 266 | \ No newline at end of file |