@@ -39,8 +39,7 @@ |
||
| 39 | 39 | try { |
| 40 | 40 | $colors = (new ReflectionClass(self::class))->getConstants(); |
| 41 | 41 | return $colors[array_rand($colors)]; |
| 42 | - } |
|
| 43 | - catch (Exception $exception) { |
|
| 42 | + } catch (Exception $exception) { |
|
| 44 | 43 | return 'none'; // unreachable |
| 45 | 44 | } |
| 46 | 45 | } |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | 'memberships' => 'memberships.(project|section)' |
| 96 | 96 | ]; |
| 97 | 97 | |
| 98 | - final public function __toString (): string { |
|
| 98 | + final public function __toString(): string { |
|
| 99 | 99 | return "tasks/{$this->getGid()}"; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * Clears the diffs for `custom_fields` and `external` sub-objects after saving. |
| 104 | 104 | */ |
| 105 | - protected function _clearSubDiffs (): void { |
|
| 105 | + protected function _clearSubDiffs(): void { |
|
| 106 | 106 | // use isset() to avoid has() fetch. |
| 107 | 107 | if (isset($this->data['custom_fields'])) { |
| 108 | 108 | $this->getCustomFields()->diff = []; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - final protected function _getDir (): string { |
|
| 115 | + final protected function _getDir(): string { |
|
| 116 | 116 | return 'tasks'; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param string $file |
| 124 | 124 | * @return Attachment |
| 125 | 125 | */ |
| 126 | - public function addAttachment (string $file) { |
|
| 126 | + public function addAttachment(string $file) { |
|
| 127 | 127 | /** @var Attachment $attachment */ |
| 128 | 128 | $attachment = $this->factory(Attachment::class, ['parent' => $this]); |
| 129 | 129 | return $attachment->upload($file); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @param string $text |
| 136 | 136 | * @return Story |
| 137 | 137 | */ |
| 138 | - public function addComment (string $text) { |
|
| 138 | + public function addComment(string $text) { |
|
| 139 | 139 | return $this->newComment()->setText($text)->create(); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param Task[] $tasks |
| 147 | 147 | * @return $this |
| 148 | 148 | */ |
| 149 | - public function addDependencies (array $tasks) { |
|
| 149 | + public function addDependencies(array $tasks) { |
|
| 150 | 150 | $this->api->post("{$this}/addDependencies", ['dependents' => array_column($tasks, 'gid')]); |
| 151 | 151 | return $this; |
| 152 | 152 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param Task $task |
| 159 | 159 | * @return $this |
| 160 | 160 | */ |
| 161 | - public function addDependency (Task $task) { |
|
| 161 | + public function addDependency(Task $task) { |
|
| 162 | 162 | return $this->addDependencies([$task]); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param Task $task |
| 170 | 170 | * @return $this |
| 171 | 171 | */ |
| 172 | - public function addDependent (Task $task) { |
|
| 172 | + public function addDependent(Task $task) { |
|
| 173 | 173 | return $this->addDependents([$task]); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param Task[] $tasks |
| 181 | 181 | * @return $this |
| 182 | 182 | */ |
| 183 | - public function addDependents (array $tasks) { |
|
| 183 | + public function addDependents(array $tasks) { |
|
| 184 | 184 | $this->api->post("{$this}/addDependents", ['dependents' => array_column($tasks, 'gid')]); |
| 185 | 185 | return $this; |
| 186 | 186 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @param User $user |
| 192 | 192 | * @return $this |
| 193 | 193 | */ |
| 194 | - public function addFollower (User $user) { |
|
| 194 | + public function addFollower(User $user) { |
|
| 195 | 195 | return $this->addFollowers([$user]); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @param User[] $users |
| 202 | 202 | * @return $this |
| 203 | 203 | */ |
| 204 | - public function addFollowers (array $users) { |
|
| 204 | + public function addFollowers(array $users) { |
|
| 205 | 205 | if ($this->hasGid()) { |
| 206 | 206 | $this->api->post("{$this}/addFollowers", ['followers' => array_column($users, 'gid')]); |
| 207 | 207 | $this->_merge('followers', $users); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @param Tag $tag |
| 219 | 219 | * @return $this |
| 220 | 220 | */ |
| 221 | - public function addTag (Tag $tag) { |
|
| 221 | + public function addTag(Tag $tag) { |
|
| 222 | 222 | if ($this->hasGid()) { |
| 223 | 223 | $this->api->post("{$this}/addTag", ['tag' => $tag->getGid()]); |
| 224 | 224 | $this->_merge('tags', [$tag]); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param Project|Section $target |
| 236 | 236 | * @return $this |
| 237 | 237 | */ |
| 238 | - public function addToProject ($target) { |
|
| 238 | + public function addToProject($target) { |
|
| 239 | 239 | if ($target instanceof Project) { |
| 240 | 240 | $project = $target; |
| 241 | 241 | $section = null; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * @param string $target |
| 277 | 277 | * @return TaskWebhook |
| 278 | 278 | */ |
| 279 | - public function addWebhook (string $target) { |
|
| 279 | + public function addWebhook(string $target) { |
|
| 280 | 280 | /** @var TaskWebhook $webhook */ |
| 281 | 281 | $webhook = $this->factory(TaskWebhook::class); |
| 282 | 282 | return $webhook->create($this, $target); |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | /** |
| 286 | 286 | * @return $this |
| 287 | 287 | */ |
| 288 | - public function create () { |
|
| 288 | + public function create() { |
|
| 289 | 289 | $this->_create(); |
| 290 | 290 | $this->_clearSubDiffs(); |
| 291 | 291 | return $this; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param string[] $include |
| 302 | 302 | * @return Job |
| 303 | 303 | */ |
| 304 | - public function duplicate (string $name, array $include) { |
|
| 304 | + public function duplicate(string $name, array $include) { |
|
| 305 | 305 | $remote = $this->api->post("{$this}/duplicate", [ |
| 306 | 306 | 'name' => $name, |
| 307 | 307 | 'include' => array_values($include) |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @depends after-create |
| 316 | 316 | * @return Attachment[] |
| 317 | 317 | */ |
| 318 | - public function getAttachments () { |
|
| 318 | + public function getAttachments() { |
|
| 319 | 319 | return $this->loadAll(Attachment::class, "{$this}/attachments"); |
| 320 | 320 | } |
| 321 | 321 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @depends after-create |
| 326 | 326 | * @return Story[] |
| 327 | 327 | */ |
| 328 | - public function getComments () { |
|
| 328 | + public function getComments() { |
|
| 329 | 329 | return array_values(array_filter($this->getStories(), function(Story $story) { |
| 330 | 330 | return $story->isComment(); |
| 331 | 331 | })); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | * @depends after-create |
| 338 | 338 | * @return Task[] |
| 339 | 339 | */ |
| 340 | - public function getDependencies () { |
|
| 340 | + public function getDependencies() { |
|
| 341 | 341 | return $this->loadAll(self::class, "{$this}/dependencies"); |
| 342 | 342 | } |
| 343 | 343 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @depends after-create |
| 348 | 348 | * @return Task[] |
| 349 | 349 | */ |
| 350 | - public function getDependents () { |
|
| 350 | + public function getDependents() { |
|
| 351 | 351 | return $this->loadAll(self::class, "{$this}/dependents"); |
| 352 | 352 | } |
| 353 | 353 | |
@@ -358,21 +358,21 @@ discard block |
||
| 358 | 358 | * @param null|string $token |
| 359 | 359 | * @return TaskEvent[]|StoryEvent[] |
| 360 | 360 | */ |
| 361 | - public function getEvents (&$token) { |
|
| 361 | + public function getEvents(&$token) { |
|
| 362 | 362 | return $this->api->sync($this, $token); |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | 366 | * @return External |
| 367 | 367 | */ |
| 368 | - public function getExternal () { |
|
| 368 | + public function getExternal() { |
|
| 369 | 369 | return $this->_get('external') ?? $this->data['external'] = $this->factory(static::$map['external']); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
| 373 | 373 | * @return Project[] |
| 374 | 374 | */ |
| 375 | - public function getProjects () { |
|
| 375 | + public function getProjects() { |
|
| 376 | 376 | return array_map(function(Membership $membership) { |
| 377 | 377 | return $membership->getProject(); |
| 378 | 378 | }, $this->getMemberships()); |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * @depends after-create |
| 385 | 385 | * @return Story[] |
| 386 | 386 | */ |
| 387 | - public function getStories () { |
|
| 387 | + public function getStories() { |
|
| 388 | 388 | return $this->loadAll(Story::class, "{$this}/stories"); |
| 389 | 389 | } |
| 390 | 390 | |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | * @depends after-create |
| 395 | 395 | * @return Task[] |
| 396 | 396 | */ |
| 397 | - public function getSubTasks () { |
|
| 397 | + public function getSubTasks() { |
|
| 398 | 398 | return $this->loadAll(self::class, "{$this}/subtasks"); |
| 399 | 399 | } |
| 400 | 400 | |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * @depends after-create |
| 405 | 405 | * @return string |
| 406 | 406 | */ |
| 407 | - public function getUrl (): string { |
|
| 407 | + public function getUrl(): string { |
|
| 408 | 408 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
| 409 | 409 | } |
| 410 | 410 | |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | * @depends after-create |
| 415 | 415 | * @return TaskWebhook[] |
| 416 | 416 | */ |
| 417 | - public function getWebhooks () { |
|
| 417 | + public function getWebhooks() { |
|
| 418 | 418 | return $this->loadAll(TaskWebhook::class, 'webhooks', [ |
| 419 | 419 | 'workspace' => $this->getWorkspace()->getGid(), |
| 420 | 420 | 'resource' => $this->getGid() |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | /** |
| 425 | 425 | * @return bool |
| 426 | 426 | */ |
| 427 | - public function isRenderedAsSeparator (): bool { |
|
| 427 | + public function isRenderedAsSeparator(): bool { |
|
| 428 | 428 | return $this->_is('is_rendered_as_separator'); |
| 429 | 429 | } |
| 430 | 430 | |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @depends after-create |
| 435 | 435 | * @return Story |
| 436 | 436 | */ |
| 437 | - public function newComment () { |
|
| 437 | + public function newComment() { |
|
| 438 | 438 | /** @var Story $comment */ |
| 439 | 439 | $comment = $this->factory(Story::class, [ |
| 440 | 440 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | * @depends after-create |
| 449 | 449 | * @return Task |
| 450 | 450 | */ |
| 451 | - public function newSubTask () { |
|
| 451 | + public function newSubTask() { |
|
| 452 | 452 | /** @var Task $sub */ |
| 453 | 453 | $sub = $this->factory(self::class); |
| 454 | 454 | return $sub->setParent($this); |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | * @param Task[] $tasks |
| 462 | 462 | * @return $this |
| 463 | 463 | */ |
| 464 | - public function removeDependencies (array $tasks) { |
|
| 464 | + public function removeDependencies(array $tasks) { |
|
| 465 | 465 | $this->api->post("{$this}/removeDependencies", ['dependencies' => array_column($tasks, 'gid')]); |
| 466 | 466 | return $this; |
| 467 | 467 | } |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | * @param Task $task |
| 474 | 474 | * @return $this |
| 475 | 475 | */ |
| 476 | - public function removeDependency (Task $task) { |
|
| 476 | + public function removeDependency(Task $task) { |
|
| 477 | 477 | return $this->removeDependencies([$task]); |
| 478 | 478 | } |
| 479 | 479 | |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | * @param Task $task |
| 485 | 485 | * @return $this |
| 486 | 486 | */ |
| 487 | - public function removeDependent (Task $task) { |
|
| 487 | + public function removeDependent(Task $task) { |
|
| 488 | 488 | return $this->removeDependents([$task]); |
| 489 | 489 | } |
| 490 | 490 | |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | * @param Task[] $tasks |
| 496 | 496 | * @return $this |
| 497 | 497 | */ |
| 498 | - public function removeDependents (array $tasks) { |
|
| 498 | + public function removeDependents(array $tasks) { |
|
| 499 | 499 | $this->api->post("{$this}/removeDependents", ['dependents' => array_column($tasks, 'gid')]); |
| 500 | 500 | return $this; |
| 501 | 501 | } |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * @param User $user |
| 507 | 507 | * @return $this |
| 508 | 508 | */ |
| 509 | - public function removeFollower (User $user) { |
|
| 509 | + public function removeFollower(User $user) { |
|
| 510 | 510 | return $this->removeFollowers([$user]); |
| 511 | 511 | } |
| 512 | 512 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | * @param User[] $users |
| 517 | 517 | * @return $this |
| 518 | 518 | */ |
| 519 | - public function removeFollowers (array $users) { |
|
| 519 | + public function removeFollowers(array $users) { |
|
| 520 | 520 | if ($this->hasGid()) { |
| 521 | 521 | $this->api->post("{$this}/removeFollowers", ['followers' => array_column($users, 'gid')]); |
| 522 | 522 | } |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | * @param Project $project |
| 531 | 531 | * @return $this |
| 532 | 532 | */ |
| 533 | - public function removeFromProject (Project $project) { |
|
| 533 | + public function removeFromProject(Project $project) { |
|
| 534 | 534 | $gid = $project->getGid(); |
| 535 | 535 | if ($this->hasGid()) { |
| 536 | 536 | $this->api->post("{$this}/removeProject", ['project' => $gid]); |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | * @param Tag $tag |
| 550 | 550 | * @return $this |
| 551 | 551 | */ |
| 552 | - public function removeTag (Tag $tag) { |
|
| 552 | + public function removeTag(Tag $tag) { |
|
| 553 | 553 | if ($this->hasGid()) { |
| 554 | 554 | $this->api->post("{$this}/removeTag", ['tag' => $tag->getGid()]); |
| 555 | 555 | } |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | * @param null|Task $parent |
| 564 | 564 | * @return $this |
| 565 | 565 | */ |
| 566 | - public function setParent (?self $parent) { |
|
| 566 | + public function setParent(?self $parent) { |
|
| 567 | 567 | if ($this->hasGid()) { |
| 568 | 568 | $this->api->post("{$this}/setParent", ['parent' => $parent ? $parent->getGid() : null]); |
| 569 | 569 | $this->data['parent'] = $parent; |
@@ -578,14 +578,14 @@ discard block |
||
| 578 | 578 | * @param bool $flag |
| 579 | 579 | * @return $this |
| 580 | 580 | */ |
| 581 | - public function setRenderedAsSeparator (bool $flag) { |
|
| 581 | + public function setRenderedAsSeparator(bool $flag) { |
|
| 582 | 582 | return $this->_set('is_rendered_as_separator', $flag); |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | /** |
| 586 | 586 | * @return $this |
| 587 | 587 | */ |
| 588 | - public function update () { |
|
| 588 | + public function update() { |
|
| 589 | 589 | $this->_update(); |
| 590 | 590 | $this->_clearSubDiffs(); |
| 591 | 591 | return $this; |
@@ -205,8 +205,7 @@ discard block |
||
| 205 | 205 | if ($this->hasGid()) { |
| 206 | 206 | $this->api->post("{$this}/addFollowers", ['followers' => array_column($users, 'gid')]); |
| 207 | 207 | $this->_merge('followers', $users); |
| 208 | - } |
|
| 209 | - else { |
|
| 208 | + } else { |
|
| 210 | 209 | $this->_merge('followers', $users, true); |
| 211 | 210 | } |
| 212 | 211 | return $this; |
@@ -222,8 +221,7 @@ discard block |
||
| 222 | 221 | if ($this->hasGid()) { |
| 223 | 222 | $this->api->post("{$this}/addTag", ['tag' => $tag->getGid()]); |
| 224 | 223 | $this->_merge('tags', [$tag]); |
| 225 | - } |
|
| 226 | - else { |
|
| 224 | + } else { |
|
| 227 | 225 | $this->_merge('tags', [$tag], true); |
| 228 | 226 | } |
| 229 | 227 | return $this; |
@@ -239,8 +237,7 @@ discard block |
||
| 239 | 237 | if ($target instanceof Project) { |
| 240 | 238 | $project = $target; |
| 241 | 239 | $section = null; |
| 242 | - } |
|
| 243 | - else { |
|
| 240 | + } else { |
|
| 244 | 241 | $project = $target->getProject(); |
| 245 | 242 | $section = $target; |
| 246 | 243 | } |
@@ -255,8 +252,7 @@ discard block |
||
| 255 | 252 | 'section' => $section |
| 256 | 253 | ]) |
| 257 | 254 | ]); |
| 258 | - } |
|
| 259 | - else { |
|
| 255 | + } else { |
|
| 260 | 256 | if (!$this->hasWorkspace()) { |
| 261 | 257 | $this->setWorkspace($project->getWorkspace()); |
| 262 | 258 | } |
@@ -567,8 +563,7 @@ discard block |
||
| 567 | 563 | if ($this->hasGid()) { |
| 568 | 564 | $this->api->post("{$this}/setParent", ['parent' => $parent ? $parent->getGid() : null]); |
| 569 | 565 | $this->data['parent'] = $parent; |
| 570 | - } |
|
| 571 | - else { |
|
| 566 | + } else { |
|
| 572 | 567 | $this->_set('parent', $parent); |
| 573 | 568 | } |
| 574 | 569 | return $this; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @return string |
| 18 | 18 | */ |
| 19 | - abstract public function __toString (): string; |
|
| 19 | + abstract public function __toString(): string; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Maps lazy-loaded / reloadable mapped {@see Data} to their proper expanded field expression. |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * Shortcut to update the cache. |
| 32 | 32 | */ |
| 33 | - protected function _cache (): void { |
|
| 33 | + protected function _cache(): void { |
|
| 34 | 34 | $this->api->getCache()->add($this); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param string $key |
| 41 | 41 | * @return mixed |
| 42 | 42 | */ |
| 43 | - protected function _get (string $key) { |
|
| 43 | + protected function _get(string $key) { |
|
| 44 | 44 | if (!array_key_exists($key, $this->data) and isset($this->data['gid'])) { // can't use hasGid(), inf. loop |
| 45 | 45 | $this->reload($key); |
| 46 | 46 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @param bool $force |
| 56 | 56 | * @return $this |
| 57 | 57 | */ |
| 58 | - protected function _merge (string $key, array $entities, $force = false) { |
|
| 58 | + protected function _merge(string $key, array $entities, $force = false) { |
|
| 59 | 59 | if ($force or isset($this->data[$key])) { |
| 60 | 60 | foreach ($entities as $entity) { |
| 61 | 61 | $this->data[$key][] = $entity; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param AbstractEntity[] $entities |
| 79 | 79 | * @return $this |
| 80 | 80 | */ |
| 81 | - protected function _remove (string $key, array $entities) { |
|
| 81 | + protected function _remove(string $key, array $entities) { |
|
| 82 | 82 | if (isset($this->data[$key])) { |
| 83 | 83 | $this->data[$key] = array_values(array_diff($this->data[$key], $entities)); |
| 84 | 84 | $this->_cache(); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return string[] |
| 93 | 93 | */ |
| 94 | - public function getCacheKeys () { |
|
| 94 | + public function getCacheKeys() { |
|
| 95 | 95 | return [$this->getGid(), (string)$this]; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param string $key |
| 102 | 102 | * @return $this |
| 103 | 103 | */ |
| 104 | - public function reload (string $key = null) { |
|
| 104 | + public function reload(string $key = null) { |
|
| 105 | 105 | if (isset($key)) { |
| 106 | 106 | $value = $this->api->get($this, [], ['fields' => static::$optFields[$key] ?? $key])[$key] ?? null; |
| 107 | 107 | $this->_setMapped($key, $value); |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | $this->data[$key] = array_values(array_unique($this->data[$key])); |
| 64 | 64 | if ($force) { |
| 65 | 65 | $this->diff[$key] = true; |
| 66 | - } |
|
| 67 | - else { |
|
| 66 | + } else { |
|
| 68 | 67 | $this->_cache(); |
| 69 | 68 | } |
| 70 | 69 | } |
@@ -105,8 +104,7 @@ discard block |
||
| 105 | 104 | if (isset($key)) { |
| 106 | 105 | $value = $this->api->get($this, [], ['fields' => static::$optFields[$key] ?? $key])[$key] ?? null; |
| 107 | 106 | $this->_setMapped($key, $value); |
| 108 | - } |
|
| 109 | - else { |
|
| 107 | + } else { |
|
| 110 | 108 | $this->_setData($this->api->get($this, [], ['expand' => 'this'])); |
| 111 | 109 | } |
| 112 | 110 | $this->_cache(); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param Api|Data $caller |
| 41 | 41 | * @param array $data |
| 42 | 42 | */ |
| 43 | - public function __construct ($caller, array $data = []) { |
|
| 43 | + public function __construct($caller, array $data = []) { |
|
| 44 | 44 | $this->api = $caller instanceof self ? $caller->api : $caller; |
| 45 | 45 | $this->_setData($data); |
| 46 | 46 | } |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | * @param array $args |
| 57 | 57 | * @return mixed |
| 58 | 58 | */ |
| 59 | - public function __call (string $method, array $args) { |
|
| 59 | + public function __call(string $method, array $args) { |
|
| 60 | 60 | static $cache = []; |
| 61 | - if (!$call =& $cache[$method]) { |
|
| 61 | + if (!$call = & $cache[$method]) { |
|
| 62 | 62 | preg_match('/^(get|has|is|set)(.+)$/', $method, $call); |
| 63 | 63 | $call[1] = '_' . $call[1]; |
| 64 | 64 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | return $this->{$call[1]}($call[2], ...$args); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function __debugInfo (): array { |
|
| 71 | + public function __debugInfo(): array { |
|
| 72 | 72 | return $this->data; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param $key |
| 79 | 79 | * @return null|Data|mixed |
| 80 | 80 | */ |
| 81 | - final public function __get ($key) { |
|
| 81 | + final public function __get($key) { |
|
| 82 | 82 | return $this->_get($key); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param $key |
| 91 | 91 | * @return bool |
| 92 | 92 | */ |
| 93 | - final public function __isset ($key) { |
|
| 93 | + final public function __isset($key) { |
|
| 94 | 94 | return true; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @param string $key |
| 103 | 103 | * @return mixed |
| 104 | 104 | */ |
| 105 | - protected function _get (string $key) { |
|
| 105 | + protected function _get(string $key) { |
|
| 106 | 106 | return $this->data[$key] ?? null; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @param string $key |
| 117 | 117 | * @return bool |
| 118 | 118 | */ |
| 119 | - protected function _has (string $key): bool { |
|
| 119 | + protected function _has(string $key): bool { |
|
| 120 | 120 | $value = $this->_get($key); |
| 121 | 121 | if (isset($value)) { |
| 122 | 122 | if (is_countable($value)) { |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param string $key |
| 140 | 140 | * @return bool |
| 141 | 141 | */ |
| 142 | - protected function _is (string $key): bool { |
|
| 142 | + protected function _is(string $key): bool { |
|
| 143 | 143 | return !empty($this->_get($key)); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param mixed $value |
| 153 | 153 | * @return $this |
| 154 | 154 | */ |
| 155 | - protected function _set (string $key, $value) { |
|
| 155 | + protected function _set(string $key, $value) { |
|
| 156 | 156 | $this->data[$key] = $value; |
| 157 | 157 | $this->diff[$key] = true; |
| 158 | 158 | return $this; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @param array $data |
| 165 | 165 | */ |
| 166 | - protected function _setData (array $data): void { |
|
| 166 | + protected function _setData(array $data): void { |
|
| 167 | 167 | $this->data = $this->diff = []; |
| 168 | 168 | foreach ($data as $key => $value) { |
| 169 | 169 | $this->_setMapped($key, $value); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @param string $key |
| 177 | 177 | * @param null|Data|array $value |
| 178 | 178 | */ |
| 179 | - protected function _setMapped (string $key, $value): void { |
|
| 179 | + protected function _setMapped(string $key, $value): void { |
|
| 180 | 180 | unset($this->diff[$key]); |
| 181 | 181 | |
| 182 | 182 | // use unmapped values, null, [], Data, and Data[] as-is |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * @param array $data |
| 217 | 217 | * @return mixed|Data|AbstractEntity |
| 218 | 218 | */ |
| 219 | - final protected function factory (string $class, array $data = []) { |
|
| 219 | + final protected function factory(string $class, array $data = []) { |
|
| 220 | 220 | return $this->api->factory($class, $this, $data); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @return array |
| 227 | 227 | */ |
| 228 | - public function getDiff (): array { |
|
| 228 | + public function getDiff(): array { |
|
| 229 | 229 | $convert = function($each) use (&$convert) { |
| 230 | 230 | // convert existing entities to gids |
| 231 | 231 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return bool |
| 252 | 252 | */ |
| 253 | - final public function isDiff (): bool { |
|
| 253 | + final public function isDiff(): bool { |
|
| 254 | 254 | return (bool)$this->diff; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @see toArray() |
| 259 | 259 | * @return array |
| 260 | 260 | */ |
| 261 | - public function jsonSerialize (): array { |
|
| 261 | + public function jsonSerialize(): array { |
|
| 262 | 262 | return $this->toArray(); |
| 263 | 263 | } |
| 264 | 264 | |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param array $query |
| 273 | 273 | * @return null|mixed|AbstractEntity |
| 274 | 274 | */ |
| 275 | - final protected function load (string $class, string $path, array $query = []) { |
|
| 275 | + final protected function load(string $class, string $path, array $query = []) { |
|
| 276 | 276 | return $this->api->load($class, $this, $path, $query); |
| 277 | 277 | } |
| 278 | 278 | |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * @param int $pages |
| 288 | 288 | * @return array|AbstractEntity[] |
| 289 | 289 | */ |
| 290 | - final protected function loadAll (string $class, string $path, array $query = [], int $pages = 0) { |
|
| 290 | + final protected function loadAll(string $class, string $path, array $query = [], int $pages = 0) { |
|
| 291 | 291 | return $this->api->loadAll($class, $this, $path, $query, $pages); |
| 292 | 292 | } |
| 293 | 293 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @return string |
| 298 | 298 | */ |
| 299 | - public function serialize (): string { |
|
| 299 | + public function serialize(): string { |
|
| 300 | 300 | return serialize($this->toArray()); |
| 301 | 301 | } |
| 302 | 302 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * |
| 306 | 306 | * @return array |
| 307 | 307 | */ |
| 308 | - public function toArray (): array { |
|
| 308 | + public function toArray(): array { |
|
| 309 | 309 | if (!$this->api) { |
| 310 | 310 | return $this->data; |
| 311 | 311 | } |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * |
| 330 | 330 | * @param $serialized |
| 331 | 331 | */ |
| 332 | - public function unserialize ($serialized): void { |
|
| 332 | + public function unserialize($serialized): void { |
|
| 333 | 333 | $this->api = Api::getDefault(); |
| 334 | 334 | $this->data = unserialize($serialized); |
| 335 | 335 | } |
@@ -14,11 +14,11 @@ |
||
| 14 | 14 | |
| 15 | 15 | const NAME = 'asana'; |
| 16 | 16 | |
| 17 | - public function boot () { |
|
| 17 | + public function boot() { |
|
| 18 | 18 | $this->mergeConfigFrom(App::configPath('asana.php'), self::NAME); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function register () { |
|
| 21 | + public function register() { |
|
| 22 | 22 | // cli: announce config file |
| 23 | 23 | if (App::runningInConsole() and !Str::contains($this->app->version(), 'Lumen')) { |
| 24 | 24 | $this->publishes([__DIR__ . '/config/asana.php' => App::configPath('asana.php')], 'config'); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param AbstractEntity $entity |
| 35 | 35 | * @return bool Success |
| 36 | 36 | */ |
| 37 | - public function add (AbstractEntity $entity): bool { |
|
| 37 | + public function add(AbstractEntity $entity): bool { |
|
| 38 | 38 | if ($gid = $entity->getGid() and !$entity->isDiff()) { |
| 39 | 39 | $this->entities[$gid] = $entity; |
| 40 | 40 | $this->addKeys($gid, $entity->getCacheKeys()); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param string $gid |
| 50 | 50 | * @param string[] $keys |
| 51 | 51 | */ |
| 52 | - protected function addKeys (string $gid, array $keys): void { |
|
| 52 | + protected function addKeys(string $gid, array $keys): void { |
|
| 53 | 53 | $this->gids += array_fill_keys($keys, $gid); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param Closure $factory `fn($caller): null|AbstractEntity` |
| 65 | 65 | * @return null|mixed|AbstractEntity |
| 66 | 66 | */ |
| 67 | - public function get (string $key, $caller, Closure $factory) { |
|
| 67 | + public function get(string $key, $caller, Closure $factory) { |
|
| 68 | 68 | // POOL HIT |
| 69 | 69 | if ($gid = $this->gids[$key] ?? null) { |
| 70 | 70 | return $this->entities[$gid]; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @param AbstractEntity $entity |
| 94 | 94 | */ |
| 95 | - public function remove (AbstractEntity $entity): void { |
|
| 95 | + public function remove(AbstractEntity $entity): void { |
|
| 96 | 96 | $gid = $entity->getGid(); |
| 97 | 97 | unset($this->entities[$gid]); |
| 98 | 98 | foreach ($entity->getCacheKeys() as $key) { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @param PSR16 $psr |
| 36 | 36 | */ |
| 37 | - public function __construct (PSR16 $psr) { |
|
| 37 | + public function __construct(PSR16 $psr) { |
|
| 38 | 38 | $this->psr = $psr; |
| 39 | 39 | $this->ttl = new DateInterval('PT1H'); |
| 40 | 40 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param string $key |
| 44 | 44 | * @throws InvalidArgumentException |
| 45 | 45 | */ |
| 46 | - protected function _delete (string $key) { |
|
| 46 | + protected function _delete(string $key) { |
|
| 47 | 47 | $this->psr->delete('asana:' . $key); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @return null|string|AbstractEntity |
| 53 | 53 | * @throws InvalidArgumentException |
| 54 | 54 | */ |
| 55 | - protected function _get (string $key) { |
|
| 55 | + protected function _get(string $key) { |
|
| 56 | 56 | return $this->psr->get('asana:' . $key); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @param mixed $value |
| 62 | 62 | * @throws InvalidArgumentException |
| 63 | 63 | */ |
| 64 | - protected function _set (string $key, $value) { |
|
| 64 | + protected function _set(string $key, $value) { |
|
| 65 | 65 | $this->psr->set('asana:' . $key, $value, $this->ttl); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @return bool |
| 71 | 71 | * @throws InvalidArgumentException |
| 72 | 72 | */ |
| 73 | - public function add (AbstractEntity $entity): bool { |
|
| 73 | + public function add(AbstractEntity $entity): bool { |
|
| 74 | 74 | if (parent::add($entity)) { |
| 75 | 75 | $this->_set($entity->getGid(), $entity); |
| 76 | 76 | return true; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param string[] $keys |
| 84 | 84 | * @throws InvalidArgumentException |
| 85 | 85 | */ |
| 86 | - protected function addKeys (string $gid, array $keys): void { |
|
| 86 | + protected function addKeys(string $gid, array $keys): void { |
|
| 87 | 87 | parent::addKeys($gid, $keys); |
| 88 | 88 | // stash gid refs |
| 89 | 89 | foreach ($keys as $key) { |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @return null|AbstractEntity |
| 101 | 101 | * @throws InvalidArgumentException |
| 102 | 102 | */ |
| 103 | - public function get (string $key, $caller, Closure $factory) { |
|
| 103 | + public function get(string $key, $caller, Closure $factory) { |
|
| 104 | 104 | // POOL MISS && CACHE HIT |
| 105 | 105 | if (!isset($this->gids[$key]) and $entity = $this->_get($key)) { |
| 106 | 106 | // dereference gid? |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | /** |
| 121 | 121 | * @return DateInterval |
| 122 | 122 | */ |
| 123 | - public function getTtl () { |
|
| 123 | + public function getTtl() { |
|
| 124 | 124 | return $this->ttl; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param AbstractEntity $entity |
| 129 | 129 | * @throws InvalidArgumentException |
| 130 | 130 | */ |
| 131 | - public function remove (AbstractEntity $entity): void { |
|
| 131 | + public function remove(AbstractEntity $entity): void { |
|
| 132 | 132 | parent::remove($entity); |
| 133 | 133 | foreach ($entity->getCacheKeys() as $key) { |
| 134 | 134 | $this->_delete($key); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param DateInterval $ttl |
| 140 | 140 | * @return $this |
| 141 | 141 | */ |
| 142 | - public function setTtl (DateInterval $ttl) { |
|
| 142 | + public function setTtl(DateInterval $ttl) { |
|
| 143 | 143 | $this->ttl = $ttl; |
| 144 | 144 | return $this; |
| 145 | 145 | } |
@@ -52,24 +52,24 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @return Cache |
| 54 | 54 | */ |
| 55 | - public static function getCache () { |
|
| 55 | + public static function getCache() { |
|
| 56 | 56 | return static::$cache ?? static::$cache = new Cache(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @return Api |
| 61 | 61 | */ |
| 62 | - public static function getDefault () { |
|
| 62 | + public static function getDefault() { |
|
| 63 | 63 | return self::$default; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * @return LoggerInterface |
| 68 | 68 | */ |
| 69 | - public static function getLogger () { |
|
| 69 | + public static function getLogger() { |
|
| 70 | 70 | return static::$logger ?? static::$logger = new class implements LoggerInterface { |
| 71 | 71 | |
| 72 | - public function log (string $info, string $path, ?array $payload): void { |
|
| 72 | + public function log(string $info, string $path, ?array $payload): void { |
|
| 73 | 73 | // stub |
| 74 | 74 | } |
| 75 | 75 | |
@@ -79,28 +79,28 @@ discard block |
||
| 79 | 79 | /** |
| 80 | 80 | * @param Cache $cache |
| 81 | 81 | */ |
| 82 | - public static function setCache (Cache $cache) { |
|
| 82 | + public static function setCache(Cache $cache) { |
|
| 83 | 83 | static::$cache = $cache; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * @param Api $default |
| 88 | 88 | */ |
| 89 | - public static function setDefault (Api $default) { |
|
| 89 | + public static function setDefault(Api $default) { |
|
| 90 | 90 | self::$default = $default; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * @param LoggerInterface $logger |
| 95 | 95 | */ |
| 96 | - public static function setLogger (LoggerInterface $logger) { |
|
| 96 | + public static function setLogger(LoggerInterface $logger) { |
|
| 97 | 97 | static::$logger = $logger; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * @param string $token |
| 102 | 102 | */ |
| 103 | - public function __construct (string $token) { |
|
| 103 | + public function __construct(string $token) { |
|
| 104 | 104 | $this->token = $token; |
| 105 | 105 | if (!static::$default) { |
| 106 | 106 | static::$default = $this; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @param string $path |
| 114 | 114 | */ |
| 115 | - public function delete (string $path): void { |
|
| 115 | + public function delete(string $path): void { |
|
| 116 | 116 | $this->exec('DELETE', $path); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @return null|array |
| 124 | 124 | * @internal |
| 125 | 125 | */ |
| 126 | - protected function exec (string $method, string $path, array $opts = null) { |
|
| 126 | + protected function exec(string $method, string $path, array $opts = null) { |
|
| 127 | 127 | $ch = curl_init(); |
| 128 | 128 | curl_setopt_array($ch, [ |
| 129 | 129 | CURLOPT_CUSTOMREQUEST => $method, |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * @param array $data |
| 175 | 175 | * @return mixed|Data|AbstractEntity |
| 176 | 176 | */ |
| 177 | - public function factory (string $class, $caller, array $data = []) { |
|
| 177 | + public function factory(string $class, $caller, array $data = []) { |
|
| 178 | 178 | return new $class($caller, $data); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @param array $options |
| 187 | 187 | * @return null|array |
| 188 | 188 | */ |
| 189 | - public function get (string $path, array $query = [], array $options = []) { |
|
| 189 | + public function get(string $path, array $query = [], array $options = []) { |
|
| 190 | 190 | foreach ($options as $name => $value) { |
| 191 | 191 | $query["opt_{$name}"] = $value; |
| 192 | 192 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param string $gid |
| 201 | 201 | * @return null|Attachment |
| 202 | 202 | */ |
| 203 | - public function getAttachment (string $gid) { |
|
| 203 | + public function getAttachment(string $gid) { |
|
| 204 | 204 | return $this->load(Attachment::class, $this, "attachments/{$gid}"); |
| 205 | 205 | } |
| 206 | 206 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @param string $gid |
| 211 | 211 | * @return null|CustomField |
| 212 | 212 | */ |
| 213 | - public function getCustomField (string $gid) { |
|
| 213 | + public function getCustomField(string $gid) { |
|
| 214 | 214 | return $this->load(CustomField::class, $this, "custom_fields/{$gid}"); |
| 215 | 215 | } |
| 216 | 216 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @return User |
| 221 | 221 | */ |
| 222 | - public function getMe () { |
|
| 222 | + public function getMe() { |
|
| 223 | 223 | return $this->getUser('me'); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | * @param array $query |
| 231 | 231 | * @return string |
| 232 | 232 | */ |
| 233 | - protected function getPath (string $path, array $query): string { |
|
| 233 | + protected function getPath(string $path, array $query): string { |
|
| 234 | 234 | return $query ? $path . '?' . http_build_query($query) : $path; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @param string $gid |
| 241 | 241 | * @return null|Portfolio |
| 242 | 242 | */ |
| 243 | - public function getPortfolio (string $gid) { |
|
| 243 | + public function getPortfolio(string $gid) { |
|
| 244 | 244 | return $this->load(Portfolio::class, $this, "portfolios/{$gid}"); |
| 245 | 245 | } |
| 246 | 246 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @param string $gid |
| 251 | 251 | * @return null|Project |
| 252 | 252 | */ |
| 253 | - public function getProject (string $gid) { |
|
| 253 | + public function getProject(string $gid) { |
|
| 254 | 254 | return $this->load(Project::class, $this, "projects/{$gid}"); |
| 255 | 255 | } |
| 256 | 256 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @param string $gid |
| 261 | 261 | * @return null|Section |
| 262 | 262 | */ |
| 263 | - public function getSection (string $gid) { |
|
| 263 | + public function getSection(string $gid) { |
|
| 264 | 264 | return $this->load(Section::class, $this, "sections/{$gid}"); |
| 265 | 265 | } |
| 266 | 266 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @param string $gid |
| 271 | 271 | * @return null|Story |
| 272 | 272 | */ |
| 273 | - public function getStory (string $gid) { |
|
| 273 | + public function getStory(string $gid) { |
|
| 274 | 274 | return $this->load(Story::class, $this, "stories/{$gid}"); |
| 275 | 275 | } |
| 276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * @param string $gid |
| 281 | 281 | * @return null|Tag |
| 282 | 282 | */ |
| 283 | - public function getTag (string $gid) { |
|
| 283 | + public function getTag(string $gid) { |
|
| 284 | 284 | return $this->load(Tag::class, $this, "tags/{$gid}"); |
| 285 | 285 | } |
| 286 | 286 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param string $gid |
| 291 | 291 | * @return null|Task |
| 292 | 292 | */ |
| 293 | - public function getTask (string $gid) { |
|
| 293 | + public function getTask(string $gid) { |
|
| 294 | 294 | return $this->load(Task::class, $this, "tasks/{$gid}"); |
| 295 | 295 | } |
| 296 | 296 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * @param string $gid |
| 301 | 301 | * @return null|Team |
| 302 | 302 | */ |
| 303 | - public function getTeam (string $gid) { |
|
| 303 | + public function getTeam(string $gid) { |
|
| 304 | 304 | return $this->load(Team::class, $this, "teams/{$gid}"); |
| 305 | 305 | } |
| 306 | 306 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * @param string $gid |
| 311 | 311 | * @return null|User |
| 312 | 312 | */ |
| 313 | - public function getUser (string $gid) { |
|
| 313 | + public function getUser(string $gid) { |
|
| 314 | 314 | return $this->load(User::class, $this, "users/{$gid}"); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * @param array $data |
| 323 | 323 | * @return ProjectEvent|TaskEvent|StoryEvent |
| 324 | 324 | */ |
| 325 | - public function getWebhookEvent (array $data) { |
|
| 325 | + public function getWebhookEvent(array $data) { |
|
| 326 | 326 | static $classes = [ |
| 327 | 327 | Project::TYPE => ProjectEvent::class, |
| 328 | 328 | Task::TYPE => TaskEvent::class, |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @param string $gid |
| 336 | 336 | * @return null|Workspace |
| 337 | 337 | */ |
| 338 | - public function getWorkspace (string $gid) { |
|
| 338 | + public function getWorkspace(string $gid) { |
|
| 339 | 339 | return $this->load(Workspace::class, $this, "workspaces/{$gid}"); |
| 340 | 340 | } |
| 341 | 341 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @param string $name |
| 344 | 344 | * @return null|Workspace |
| 345 | 345 | */ |
| 346 | - public function getWorkspaceByName (string $name) { |
|
| 346 | + public function getWorkspaceByName(string $name) { |
|
| 347 | 347 | foreach ($this->getMe()->getWorkspaces() as $workspace) { |
| 348 | 348 | if ($workspace->getName() === $name) { |
| 349 | 349 | return $workspace; |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | * @param string $json |
| 357 | 357 | * @return null|array |
| 358 | 358 | */ |
| 359 | - protected function jsonDecode (string $json) { |
|
| 360 | - return json_decode($json, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 359 | + protected function jsonDecode(string $json) { |
|
| 360 | + return json_decode($json, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
| 364 | 364 | * @param array $data |
| 365 | 365 | * @return string |
| 366 | 366 | */ |
| 367 | - protected function jsonEncode (array $data): string { |
|
| 368 | - return json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
|
| 367 | + protected function jsonEncode(array $data): string { |
|
| 368 | + return json_encode($data, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | * @param array $query |
| 380 | 380 | * @return null|mixed|AbstractEntity |
| 381 | 381 | */ |
| 382 | - public function load (string $class, $caller, string $path, array $query = []) { |
|
| 382 | + public function load(string $class, $caller, string $path, array $query = []) { |
|
| 383 | 383 | $key = $this->getPath($path, $query); |
| 384 | 384 | return $this->getCache()->get($key, $caller, function($caller) use ($class, $path, $query) { |
| 385 | 385 | $data = $this->get($path, $query, ['expand' => 'this']); |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | * @param int $pages If positive, stops after this many pages have been fetched. |
| 400 | 400 | * @return array|AbstractEntity[] |
| 401 | 401 | */ |
| 402 | - public function loadAll (string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
| 402 | + public function loadAll(string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
| 403 | 403 | $query['opt_expand'] = 'this'; |
| 404 | 404 | $query += ['limit' => 100]; |
| 405 | 405 | $path = $this->getPath($path, $query); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | * @param array $options |
| 426 | 426 | * @return null|array |
| 427 | 427 | */ |
| 428 | - public function post (string $path, array $data = [], array $options = []) { |
|
| 428 | + public function post(string $path, array $data = [], array $options = []) { |
|
| 429 | 429 | $response = $this->exec('POST', $path, [ |
| 430 | 430 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 431 | 431 | CURLOPT_POSTFIELDS => $this->jsonEncode(['options' => $options, 'data' => $data]) |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | * @param array $options |
| 442 | 442 | * @return null|array |
| 443 | 443 | */ |
| 444 | - public function put (string $path, array $data = [], array $options = []) { |
|
| 444 | + public function put(string $path, array $data = [], array $options = []) { |
|
| 445 | 445 | $response = $this->exec('PUT', $path, [ |
| 446 | 446 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 447 | 447 | CURLOPT_POSTFIELDS => $this->jsonEncode(['options' => $options, 'data' => $data]) |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | * @param null|string $token |
| 461 | 461 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
| 462 | 462 | */ |
| 463 | - public function sync ($entity, ?string &$token) { |
|
| 463 | + public function sync($entity, ?string &$token) { |
|
| 464 | 464 | try { |
| 465 | 465 | $response = $this->exec('GET', $this->getPath('events', [ |
| 466 | 466 | 'resource' => $entity->getGid(), |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | * @param string $file |
| 496 | 496 | * @return null|array |
| 497 | 497 | */ |
| 498 | - public function upload (string $path, string $file) { |
|
| 498 | + public function upload(string $path, string $file) { |
|
| 499 | 499 | $response = $this->exec('POST', $path, [ |
| 500 | 500 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
| 501 | 501 | ]); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | 'workspaces' => [Workspace::class] |
| 29 | 29 | ]; |
| 30 | 30 | |
| 31 | - final public function __toString (): string { |
|
| 31 | + final public function __toString(): string { |
|
| 32 | 32 | return "users/{$this->getGid()}"; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param Workspace $workspace |
| 37 | 37 | * @return $this |
| 38 | 38 | */ |
| 39 | - public function addToWorkspace (Workspace $workspace) { |
|
| 39 | + public function addToWorkspace(Workspace $workspace) { |
|
| 40 | 40 | $this->api->post("{$workspace}/addUser", ['user' => $this->getGid()]); |
| 41 | 41 | $this->_merge('workspaces', [$workspace]); |
| 42 | 42 | return $this; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * @return string[] |
| 47 | 47 | */ |
| 48 | - public function getCacheKeys () { |
|
| 48 | + public function getCacheKeys() { |
|
| 49 | 49 | $keys = parent::getCacheKeys(); |
| 50 | 50 | |
| 51 | 51 | // only include email as a key if it's loaded |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param Workspace $workspace |
| 61 | 61 | * @return Portfolio[] |
| 62 | 62 | */ |
| 63 | - public function getFavoritePortfolios (Workspace $workspace) { |
|
| 63 | + public function getFavoritePortfolios(Workspace $workspace) { |
|
| 64 | 64 | return $this->getFavorites(Portfolio::class, Portfolio::TYPE, $workspace); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param Workspace $workspace |
| 69 | 69 | * @return Project[] |
| 70 | 70 | */ |
| 71 | - public function getFavoriteProjects (Workspace $workspace) { |
|
| 71 | + public function getFavoriteProjects(Workspace $workspace) { |
|
| 72 | 72 | return $this->getFavorites(Project::class, Project::TYPE, $workspace); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @param Workspace $workspace |
| 77 | 77 | * @return Tag[] |
| 78 | 78 | */ |
| 79 | - public function getFavoriteTags (Workspace $workspace) { |
|
| 79 | + public function getFavoriteTags(Workspace $workspace) { |
|
| 80 | 80 | return $this->getFavorites(Tag::class, Tag::TYPE, $workspace); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param Workspace $workspace |
| 85 | 85 | * @return Team[] |
| 86 | 86 | */ |
| 87 | - public function getFavoriteTeams (Workspace $workspace) { |
|
| 87 | + public function getFavoriteTeams(Workspace $workspace) { |
|
| 88 | 88 | return $this->getFavorites(Team::class, Team::TYPE, $workspace); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param Workspace $workspace |
| 93 | 93 | * @return User[] |
| 94 | 94 | */ |
| 95 | - public function getFavoriteUsers (Workspace $workspace) { |
|
| 95 | + public function getFavoriteUsers(Workspace $workspace) { |
|
| 96 | 96 | return $this->getFavorites(self::class, self::TYPE, $workspace); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @param Workspace $workspace |
| 103 | 103 | * @return array |
| 104 | 104 | */ |
| 105 | - protected function getFavorites (string $class, string $resourceType, Workspace $workspace) { |
|
| 105 | + protected function getFavorites(string $class, string $resourceType, Workspace $workspace) { |
|
| 106 | 106 | return $this->loadAll($class, "{$this}/favorites", [ |
| 107 | 107 | 'resource_type' => $resourceType, |
| 108 | 108 | 'workspace' => $workspace->getGid() |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @param Workspace $workspace |
| 118 | 118 | * @return Task[] |
| 119 | 119 | */ |
| 120 | - public function getIncompleteTasks (Workspace $workspace) { |
|
| 120 | + public function getIncompleteTasks(Workspace $workspace) { |
|
| 121 | 121 | return $this->loadAll(Task::class, 'tasks', [ |
| 122 | 122 | 'assignee' => $this->getGid(), |
| 123 | 123 | 'workspace' => $workspace->getGid(), |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @param Workspace $workspace |
| 130 | 130 | * @return Portfolio[] |
| 131 | 131 | */ |
| 132 | - public function getPortfolios (Workspace $workspace) { |
|
| 132 | + public function getPortfolios(Workspace $workspace) { |
|
| 133 | 133 | return $this->loadAll(Portfolio::class, "portfolios", [ |
| 134 | 134 | 'workspace' => $workspace->getGid(), |
| 135 | 135 | 'owner' => $this->getGid() |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @param Workspace $workspace |
| 141 | 141 | * @return TaskList |
| 142 | 142 | */ |
| 143 | - public function getTaskList (Workspace $workspace) { |
|
| 143 | + public function getTaskList(Workspace $workspace) { |
|
| 144 | 144 | return $this->load(TaskList::class, "{$this}/user_task_list", [ |
| 145 | 145 | 'workspace' => $workspace->getGid() |
| 146 | 146 | ]); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param string[] $filter |
| 156 | 156 | * @return Task[] |
| 157 | 157 | */ |
| 158 | - public function getTasks (Workspace $workspace, array $filter = []) { |
|
| 158 | + public function getTasks(Workspace $workspace, array $filter = []) { |
|
| 159 | 159 | $filter['assignee'] = $this->getGid(); |
| 160 | 160 | $filter['workspace'] = $workspace->getGid(); |
| 161 | 161 | return $this->loadAll(Task::class, 'tasks', $filter); |
@@ -165,13 +165,13 @@ discard block |
||
| 165 | 165 | * @param Workspace $organization |
| 166 | 166 | * @return Team[] |
| 167 | 167 | */ |
| 168 | - public function getTeams (Workspace $organization) { |
|
| 168 | + public function getTeams(Workspace $organization) { |
|
| 169 | 169 | return $this->loadAll(Team::class, "{$this}/teams", [ |
| 170 | 170 | 'organization' => $organization->getGid() |
| 171 | 171 | ]); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - public function getUrl (): string { |
|
| 174 | + public function getUrl(): string { |
|
| 175 | 175 | return "https://app.asana.com/0/{$this->getGid()}/list"; |
| 176 | 176 | } |
| 177 | 177 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * @param Workspace $workspace |
| 180 | 180 | * @return $this |
| 181 | 181 | */ |
| 182 | - public function removeFromWorkspace (Workspace $workspace) { |
|
| 182 | + public function removeFromWorkspace(Workspace $workspace) { |
|
| 183 | 183 | $this->api->post("{$workspace}/removeUser", ['user' => $this->getGid()]); |
| 184 | 184 | $this->_remove('workspaces', [$workspace]); |
| 185 | 185 | return $this; |