@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string $token |
43 | 43 | * @param null|Pool $pool |
44 | 44 | */ |
45 | - public function __construct (string $token, Pool $pool = null) { |
|
45 | + public function __construct(string $token, Pool $pool = null) { |
|
46 | 46 | $this->token = $token; |
47 | 47 | $this->pool = $pool ?? new Pool(); |
48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param array $curlOpts |
56 | 56 | * @return null|array |
57 | 57 | */ |
58 | - public function call (string $method, string $path, array $curlOpts = []) { |
|
58 | + public function call(string $method, string $path, array $curlOpts = []) { |
|
59 | 59 | $log = $this->getLog(); |
60 | 60 | $log->log(LOG_DEBUG, "{$method} {$path}", $curlOpts); |
61 | 61 | /** @var resource $ch */ |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | switch ($curlInfo['http_code']) { |
87 | 87 | case 200: |
88 | 88 | case 201: |
89 | - return json_decode($body, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
89 | + return json_decode($body, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
90 | 90 | case 404: |
91 | 91 | return null; |
92 | 92 | case 429: |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @param string $path |
107 | 107 | */ |
108 | - public function delete (string $path): void { |
|
108 | + public function delete(string $path): void { |
|
109 | 109 | $this->call('DELETE', $path); |
110 | 110 | } |
111 | 111 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param array $data |
120 | 120 | * @return mixed|Data|AbstractEntity |
121 | 121 | */ |
122 | - public function factory ($caller, string $class, array $data = []) { |
|
122 | + public function factory($caller, string $class, array $data = []) { |
|
123 | 123 | return new $class($caller, $data); |
124 | 124 | } |
125 | 125 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param array $opt |
132 | 132 | * @return null|array |
133 | 133 | */ |
134 | - public function get (string $path, array $query = [], array $opt = []) { |
|
134 | + public function get(string $path, array $query = [], array $opt = []) { |
|
135 | 135 | foreach ($opt as $name => $value) { |
136 | 136 | $query["opt_{$name}"] = $value; |
137 | 137 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @param string $gid |
146 | 146 | * @return null|Attachment |
147 | 147 | */ |
148 | - public function getAttachment (string $gid) { |
|
148 | + public function getAttachment(string $gid) { |
|
149 | 149 | return $this->load($this, Attachment::class, "attachments/{$gid}"); |
150 | 150 | } |
151 | 151 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string $gid |
156 | 156 | * @return null|CustomField |
157 | 157 | */ |
158 | - public function getCustomField (string $gid) { |
|
158 | + public function getCustomField(string $gid) { |
|
159 | 159 | return $this->load($this, CustomField::class, "custom_fields/{$gid}"); |
160 | 160 | } |
161 | 161 | |
@@ -166,28 +166,28 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return Workspace |
168 | 168 | */ |
169 | - public function getDefaultWorkspace () { |
|
169 | + public function getDefaultWorkspace() { |
|
170 | 170 | return $this->getMe()->getDefaultWorkspace(); |
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | 174 | * @return LoggerInterface |
175 | 175 | */ |
176 | - public function getLog () { |
|
176 | + public function getLog() { |
|
177 | 177 | return $this->log ?? $this->log = new NullLogger(); |
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | 181 | * @return User |
182 | 182 | */ |
183 | - public function getMe () { |
|
183 | + public function getMe() { |
|
184 | 184 | return $this->getUser('me'); |
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
188 | 188 | * @return Pool |
189 | 189 | */ |
190 | - public function getPool () { |
|
190 | + public function getPool() { |
|
191 | 191 | return $this->pool; |
192 | 192 | } |
193 | 193 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param string $gid |
198 | 198 | * @return null|Portfolio |
199 | 199 | */ |
200 | - public function getPortfolio (string $gid) { |
|
200 | + public function getPortfolio(string $gid) { |
|
201 | 201 | return $this->load($this, Portfolio::class, "portfolios/{$gid}"); |
202 | 202 | } |
203 | 203 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param string $gid |
208 | 208 | * @return null|Project |
209 | 209 | */ |
210 | - public function getProject (string $gid) { |
|
210 | + public function getProject(string $gid) { |
|
211 | 211 | return $this->load($this, Project::class, "projects/{$gid}"); |
212 | 212 | } |
213 | 213 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param string $gid |
218 | 218 | * @return null|Section |
219 | 219 | */ |
220 | - public function getSection (string $gid) { |
|
220 | + public function getSection(string $gid) { |
|
221 | 221 | return $this->load($this, Section::class, "sections/{$gid}"); |
222 | 222 | } |
223 | 223 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param string $gid |
228 | 228 | * @return null|Story |
229 | 229 | */ |
230 | - public function getStory (string $gid) { |
|
230 | + public function getStory(string $gid) { |
|
231 | 231 | return $this->load($this, Story::class, "stories/{$gid}"); |
232 | 232 | } |
233 | 233 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param string $gid |
238 | 238 | * @return null|Tag |
239 | 239 | */ |
240 | - public function getTag (string $gid) { |
|
240 | + public function getTag(string $gid) { |
|
241 | 241 | return $this->load($this, Tag::class, "tags/{$gid}"); |
242 | 242 | } |
243 | 243 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @param string $gid |
248 | 248 | * @return null|Task |
249 | 249 | */ |
250 | - public function getTask (string $gid) { |
|
250 | + public function getTask(string $gid) { |
|
251 | 251 | return $this->load($this, Task::class, "tasks/{$gid}"); |
252 | 252 | } |
253 | 253 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @param string $gid |
258 | 258 | * @return null|TaskList |
259 | 259 | */ |
260 | - public function getTaskList (string $gid) { |
|
260 | + public function getTaskList(string $gid) { |
|
261 | 261 | return $this->load($this, TaskList::class, "user_task_lists/{$gid}"); |
262 | 262 | } |
263 | 263 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @param string $gid |
268 | 268 | * @return null|Team |
269 | 269 | */ |
270 | - public function getTeam (string $gid) { |
|
270 | + public function getTeam(string $gid) { |
|
271 | 271 | return $this->load($this, Team::class, "teams/{$gid}"); |
272 | 272 | } |
273 | 273 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param string $gid |
278 | 278 | * @return null|User |
279 | 279 | */ |
280 | - public function getUser (string $gid) { |
|
280 | + public function getUser(string $gid) { |
|
281 | 281 | return $this->load($this, User::class, "users/{$gid}"); |
282 | 282 | } |
283 | 283 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @param string $gid |
286 | 286 | * @return ProjectWebhook|TaskWebhook |
287 | 287 | */ |
288 | - public function getWebhook (string $gid) { |
|
288 | + public function getWebhook(string $gid) { |
|
289 | 289 | return $this->pool->get($gid, $this, function() use ($gid) { |
290 | 290 | static $classes = [ |
291 | 291 | Project::TYPE => ProjectWebhook::class, |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @param array $data |
307 | 307 | * @return Event |
308 | 308 | */ |
309 | - public function getWebhookEvent (array $data) { |
|
309 | + public function getWebhookEvent(array $data) { |
|
310 | 310 | return $this->factory($this, Event::class, $data); |
311 | 311 | } |
312 | 312 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @param string $gid |
317 | 317 | * @return null|Workspace |
318 | 318 | */ |
319 | - public function getWorkspace (string $gid) { |
|
319 | + public function getWorkspace(string $gid) { |
|
320 | 320 | return $this->load($this, Workspace::class, "workspaces/{$gid}"); |
321 | 321 | } |
322 | 322 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @param array $query |
330 | 330 | * @return null|mixed|AbstractEntity |
331 | 331 | */ |
332 | - public function load ($caller, string $class, string $path, array $query = []) { |
|
332 | + public function load($caller, string $class, string $path, array $query = []) { |
|
333 | 333 | $key = rtrim($path . '?' . http_build_query($query), '?'); |
334 | 334 | return $this->pool->get($key, $caller, function($caller) use ($class, $path, $query) { |
335 | 335 | if ($data = $this->get($path, $query, ['expand' => 'this'])) { |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @param array $query |
349 | 349 | * @return array|AbstractEntity[] |
350 | 350 | */ |
351 | - public function loadAll ($caller, string $class, string $path, array $query = []) { |
|
351 | + public function loadAll($caller, string $class, string $path, array $query = []) { |
|
352 | 352 | return iterator_to_array($this->loadEach(...func_get_args())); |
353 | 353 | } |
354 | 354 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @param array $query `limit` can exceed `100` here. |
364 | 364 | * @return Generator|AbstractEntity[] |
365 | 365 | */ |
366 | - public function loadEach ($caller, string $class, string $path, array $query = []) { |
|
366 | + public function loadEach($caller, string $class, string $path, array $query = []) { |
|
367 | 367 | $query['opt_expand'] = 'this'; |
368 | 368 | $remain = $query['limit'] ?? PHP_INT_MAX; |
369 | 369 | do { |
@@ -387,13 +387,13 @@ discard block |
||
387 | 387 | * @param array $opt |
388 | 388 | * @return null|array |
389 | 389 | */ |
390 | - public function post (string $path, array $data = [], array $opt = []) { |
|
390 | + public function post(string $path, array $data = [], array $opt = []) { |
|
391 | 391 | $response = $this->call('POST', $path, [ |
392 | 392 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
393 | 393 | CURLOPT_POSTFIELDS => json_encode([ |
394 | 394 | 'options' => $opt, |
395 | 395 | 'data' => $data |
396 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
396 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
397 | 397 | ]); |
398 | 398 | return $response['data'] ?? null; |
399 | 399 | } |
@@ -406,13 +406,13 @@ discard block |
||
406 | 406 | * @param array $opt |
407 | 407 | * @return null|array |
408 | 408 | */ |
409 | - public function put (string $path, array $data = [], array $opt = []) { |
|
409 | + public function put(string $path, array $data = [], array $opt = []) { |
|
410 | 410 | $response = $this->call('PUT', $path, [ |
411 | 411 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
412 | 412 | CURLOPT_POSTFIELDS => json_encode([ |
413 | 413 | 'options' => $opt, |
414 | 414 | 'data' => $data |
415 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
415 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
416 | 416 | ]); |
417 | 417 | return $response['data'] ?? null; |
418 | 418 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | /** |
421 | 421 | * @param LoggerInterface $log |
422 | 422 | */ |
423 | - public function setLog (LoggerInterface $log) { |
|
423 | + public function setLog(LoggerInterface $log) { |
|
424 | 424 | $this->log = $log; |
425 | 425 | } |
426 | 426 | } |
427 | 427 | \ No newline at end of file |