@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $token |
44 | 44 | * @param null|Pool $pool |
45 | 45 | */ |
46 | - public function __construct (string $token, Pool $pool = null) { |
|
46 | + public function __construct(string $token, Pool $pool = null) { |
|
47 | 47 | $this->token = $token; |
48 | 48 | $this->pool = $pool ?? new Pool(); |
49 | 49 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param array $curlOpts |
57 | 57 | * @return null|array |
58 | 58 | */ |
59 | - public function call (string $method, string $path, array $curlOpts = []) { |
|
59 | + public function call(string $method, string $path, array $curlOpts = []) { |
|
60 | 60 | $this->getLog()->log(LOG_DEBUG, "{$method} {$path}", $curlOpts); |
61 | 61 | $curlOpts[CURLOPT_HTTPHEADER][] = "Authorization: Bearer {$this->token}"; |
62 | 62 | $curlOpts[CURLOPT_HTTPHEADER][] = 'Accept: application/json'; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | throw new AsanaError(curl_errno($ch), curl_error($ch), $info); |
80 | 80 | case 200: |
81 | 81 | case 201: |
82 | - return json_decode($res[1], true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
82 | + return json_decode($res[1], true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
83 | 83 | case 404: |
84 | 84 | return null; |
85 | 85 | case 429: |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param string $path |
101 | 101 | */ |
102 | - public function delete (string $path): void { |
|
102 | + public function delete(string $path): void { |
|
103 | 103 | $this->call('DELETE', $path); |
104 | 104 | } |
105 | 105 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param array $data |
114 | 114 | * @return mixed|Data|AbstractEntity |
115 | 115 | */ |
116 | - public function factory ($caller, string $class, array $data = []) { |
|
116 | + public function factory($caller, string $class, array $data = []) { |
|
117 | 117 | return new $class($caller, $data); |
118 | 118 | } |
119 | 119 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param array $query |
125 | 125 | * @return null|array |
126 | 126 | */ |
127 | - public function get (string $path, array $query = []) { |
|
127 | + public function get(string $path, array $query = []) { |
|
128 | 128 | return $this->call('GET', $path . '?' . http_build_query($query))['data'] ?? null; |
129 | 129 | } |
130 | 130 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param string $gid |
135 | 135 | * @return null|Attachment |
136 | 136 | */ |
137 | - public function getAttachment (string $gid) { |
|
137 | + public function getAttachment(string $gid) { |
|
138 | 138 | return $this->load($this, Attachment::class, "attachments/{$gid}"); |
139 | 139 | } |
140 | 140 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param string $gid |
145 | 145 | * @return null|CustomField |
146 | 146 | */ |
147 | - public function getCustomField (string $gid) { |
|
147 | + public function getCustomField(string $gid) { |
|
148 | 148 | return $this->load($this, CustomField::class, "custom_fields/{$gid}"); |
149 | 149 | } |
150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return Workspace |
157 | 157 | */ |
158 | - public function getDefaultWorkspace () { |
|
158 | + public function getDefaultWorkspace() { |
|
159 | 159 | return $this->getMe()->getDefaultWorkspace(); |
160 | 160 | } |
161 | 161 | |
@@ -163,21 +163,21 @@ discard block |
||
163 | 163 | * @param string $gid |
164 | 164 | * @return null|Job |
165 | 165 | */ |
166 | - public function getJob (string $gid) { |
|
166 | + public function getJob(string $gid) { |
|
167 | 167 | return $this->load($this, Job::class, "jobs/{$gid}"); |
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
171 | 171 | * @return LoggerInterface |
172 | 172 | */ |
173 | - public function getLog () { |
|
173 | + public function getLog() { |
|
174 | 174 | return $this->log ?? $this->log = new NullLogger(); |
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | 178 | * @return User |
179 | 179 | */ |
180 | - public function getMe () { |
|
180 | + public function getMe() { |
|
181 | 181 | return $this->getUser('me'); |
182 | 182 | } |
183 | 183 | |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | * @param string $gid |
186 | 186 | * @return null|OrganizationExport |
187 | 187 | */ |
188 | - public function getOrganizationExport (string $gid) { |
|
188 | + public function getOrganizationExport(string $gid) { |
|
189 | 189 | return $this->load($this, OrganizationExport::class, "organization_exports/{$gid}"); |
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
193 | 193 | * @return Pool |
194 | 194 | */ |
195 | - public function getPool () { |
|
195 | + public function getPool() { |
|
196 | 196 | return $this->pool; |
197 | 197 | } |
198 | 198 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param string $gid |
203 | 203 | * @return null|Portfolio |
204 | 204 | */ |
205 | - public function getPortfolio (string $gid) { |
|
205 | + public function getPortfolio(string $gid) { |
|
206 | 206 | return $this->load($this, Portfolio::class, "portfolios/{$gid}"); |
207 | 207 | } |
208 | 208 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param string $gid |
213 | 213 | * @return null|Project |
214 | 214 | */ |
215 | - public function getProject (string $gid) { |
|
215 | + public function getProject(string $gid) { |
|
216 | 216 | return $this->load($this, Project::class, "projects/{$gid}"); |
217 | 217 | } |
218 | 218 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param string $gid |
221 | 221 | * @return null|ProjectWebhook |
222 | 222 | */ |
223 | - public function getProjectWebhook (string $gid) { |
|
223 | + public function getProjectWebhook(string $gid) { |
|
224 | 224 | return $this->load($this, ProjectWebhook::class, "webhooks/{$gid}"); |
225 | 225 | } |
226 | 226 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @param string $gid |
231 | 231 | * @return null|Section |
232 | 232 | */ |
233 | - public function getSection (string $gid) { |
|
233 | + public function getSection(string $gid) { |
|
234 | 234 | return $this->load($this, Section::class, "sections/{$gid}"); |
235 | 235 | } |
236 | 236 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param string $gid |
241 | 241 | * @return null|Story |
242 | 242 | */ |
243 | - public function getStory (string $gid) { |
|
243 | + public function getStory(string $gid) { |
|
244 | 244 | return $this->load($this, Story::class, "stories/{$gid}"); |
245 | 245 | } |
246 | 246 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param string $gid |
251 | 251 | * @return null|Tag |
252 | 252 | */ |
253 | - public function getTag (string $gid) { |
|
253 | + public function getTag(string $gid) { |
|
254 | 254 | return $this->load($this, Tag::class, "tags/{$gid}"); |
255 | 255 | } |
256 | 256 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param string $gid |
261 | 261 | * @return null|Task |
262 | 262 | */ |
263 | - public function getTask (string $gid) { |
|
263 | + public function getTask(string $gid) { |
|
264 | 264 | return $this->load($this, Task::class, "tasks/{$gid}"); |
265 | 265 | } |
266 | 266 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param string $gid |
271 | 271 | * @return null|TaskList |
272 | 272 | */ |
273 | - public function getTaskList (string $gid) { |
|
273 | + public function getTaskList(string $gid) { |
|
274 | 274 | return $this->load($this, TaskList::class, "user_task_lists/{$gid}"); |
275 | 275 | } |
276 | 276 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param string $gid |
279 | 279 | * @return null|TaskWebhook |
280 | 280 | */ |
281 | - public function getTaskWebhook (string $gid) { |
|
281 | + public function getTaskWebhook(string $gid) { |
|
282 | 282 | return $this->load($this, TaskWebhook::class, "webhooks/{$gid}"); |
283 | 283 | } |
284 | 284 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param string $gid |
289 | 289 | * @return null|Team |
290 | 290 | */ |
291 | - public function getTeam (string $gid) { |
|
291 | + public function getTeam(string $gid) { |
|
292 | 292 | return $this->load($this, Team::class, "teams/{$gid}"); |
293 | 293 | } |
294 | 294 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @param string $gid |
299 | 299 | * @return null|User |
300 | 300 | */ |
301 | - public function getUser (string $gid) { |
|
301 | + public function getUser(string $gid) { |
|
302 | 302 | return $this->load($this, User::class, "users/{$gid}"); |
303 | 303 | } |
304 | 304 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @param array $data |
311 | 311 | * @return Event |
312 | 312 | */ |
313 | - public function getWebhookEvent (array $data) { |
|
313 | + public function getWebhookEvent(array $data) { |
|
314 | 314 | return $this->factory($this, Event::class, $data); |
315 | 315 | } |
316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @param string $gid |
321 | 321 | * @return null|Workspace |
322 | 322 | */ |
323 | - public function getWorkspace (string $gid) { |
|
323 | + public function getWorkspace(string $gid) { |
|
324 | 324 | return $this->load($this, Workspace::class, "workspaces/{$gid}"); |
325 | 325 | } |
326 | 326 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @param array $query |
334 | 334 | * @return null|mixed|AbstractEntity |
335 | 335 | */ |
336 | - public function load ($caller, string $class, string $path, array $query = []) { |
|
336 | + public function load($caller, string $class, string $path, array $query = []) { |
|
337 | 337 | $key = rtrim($path . '?' . http_build_query($query), '?'); |
338 | 338 | $query['opt_expand'] = 'this'; |
339 | 339 | return $this->pool->get($key, $caller, function($caller) use ($class, $path, $query) { |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param array $query |
354 | 354 | * @return array|AbstractEntity[] |
355 | 355 | */ |
356 | - public function loadAll ($caller, string $class, string $path, array $query = []) { |
|
356 | + public function loadAll($caller, string $class, string $path, array $query = []) { |
|
357 | 357 | return iterator_to_array($this->loadEach(...func_get_args())); |
358 | 358 | } |
359 | 359 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @param array $query `limit` can exceed `100` here. |
369 | 369 | * @return Generator|AbstractEntity[] |
370 | 370 | */ |
371 | - public function loadEach ($caller, string $class, string $path, array $query = []) { |
|
371 | + public function loadEach($caller, string $class, string $path, array $query = []) { |
|
372 | 372 | $query['opt_expand'] = 'this'; |
373 | 373 | $remain = $query['limit'] ?? PHP_INT_MAX; |
374 | 374 | do { |
@@ -392,13 +392,13 @@ discard block |
||
392 | 392 | * @param array $options |
393 | 393 | * @return null|array |
394 | 394 | */ |
395 | - public function post (string $path, array $data = [], array $options = []) { |
|
395 | + public function post(string $path, array $data = [], array $options = []) { |
|
396 | 396 | return $this->call('POST', $path, [ |
397 | 397 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
398 | 398 | CURLOPT_POSTFIELDS => json_encode([ |
399 | 399 | 'options' => $options, |
400 | 400 | 'data' => $data |
401 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
401 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
402 | 402 | ])['data'] ?? null; |
403 | 403 | } |
404 | 404 | |
@@ -410,20 +410,20 @@ discard block |
||
410 | 410 | * @param array $options |
411 | 411 | * @return null|array |
412 | 412 | */ |
413 | - public function put (string $path, array $data = [], array $options = []) { |
|
413 | + public function put(string $path, array $data = [], array $options = []) { |
|
414 | 414 | return $this->call('PUT', $path, [ |
415 | 415 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
416 | 416 | CURLOPT_POSTFIELDS => json_encode([ |
417 | 417 | 'options' => $options, |
418 | 418 | 'data' => $data |
419 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
419 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
420 | 420 | ])['data'] ?? null; |
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
424 | 424 | * @param LoggerInterface $log |
425 | 425 | */ |
426 | - public function setLog (LoggerInterface $log) { |
|
426 | + public function setLog(LoggerInterface $log) { |
|
427 | 427 | $this->log = $log; |
428 | 428 | } |
429 | 429 | } |
430 | 430 | \ No newline at end of file |