@@ -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 fields to their proper expanded field expression. |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param AbstractEntity[] $entities |
| 34 | 34 | * @return string[] |
| 35 | 35 | */ |
| 36 | - protected static function _getGids (array $entities) { |
|
| 36 | + protected static function _getGids(array $entities) { |
|
| 37 | 37 | return array_map(function(AbstractEntity $entity) { |
| 38 | 38 | return $entity->getGid(); |
| 39 | 39 | }, $entities); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param string $key |
| 46 | 46 | * @return mixed |
| 47 | 47 | */ |
| 48 | - protected function _get (string $key) { |
|
| 48 | + protected function _get(string $key) { |
|
| 49 | 49 | if (!array_key_exists($key, $this->data) and isset($this->data['gid'])) { // can't use hasGid(), inf. loop |
| 50 | 50 | $this->reload($key); |
| 51 | 51 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param bool $force |
| 61 | 61 | * @return $this |
| 62 | 62 | */ |
| 63 | - protected function _merge (string $key, array $entities, $force = false) { |
|
| 63 | + protected function _merge(string $key, array $entities, $force = false) { |
|
| 64 | 64 | if ($force or isset($this->data[$key])) { |
| 65 | 65 | foreach ($entities as $entity) { |
| 66 | 66 | $this->data[$key][] = $entity; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param AbstractEntity[] $entities |
| 84 | 84 | * @return $this |
| 85 | 85 | */ |
| 86 | - protected function _remove (string $key, array $entities) { |
|
| 86 | + protected function _remove(string $key, array $entities) { |
|
| 87 | 87 | if (isset($this->data[$key])) { |
| 88 | 88 | $this->data[$key] = array_values(array_diff($this->data[$key], $entities)); |
| 89 | 89 | $this->api->getCache()->add($this); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param AbstractEntity $entity |
| 98 | 98 | * @return $this |
| 99 | 99 | */ |
| 100 | - public function merge (AbstractEntity $entity) { |
|
| 100 | + public function merge(AbstractEntity $entity) { |
|
| 101 | 101 | assert($entity->api); // hydrated |
| 102 | 102 | foreach ($entity->data as $key => $value) { |
| 103 | 103 | if (!array_key_exists($key, $this->data) and !isset($entity->diff[$key])) { |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @param string $key |
| 114 | 114 | * @return $this |
| 115 | 115 | */ |
| 116 | - public function reload (string $key = null) { |
|
| 116 | + public function reload(string $key = null) { |
|
| 117 | 117 | if (isset($key)) { |
| 118 | 118 | $value = $this->api->get($this, [], ['fields' => $this->optFields[$key] ?? $key])[$key] ?? null; |
| 119 | 119 | $map = $this->_getMap(); |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | 'memberships' => 'memberships.(project|section)' |
| 84 | 84 | ]; |
| 85 | 85 | |
| 86 | - final public function __toString (): string { |
|
| 86 | + final public function __toString(): string { |
|
| 87 | 87 | return "tasks/{$this->getGid()}"; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Clears the diffs for `custom_fields` and `external` sub-objects after saving. |
| 92 | 92 | */ |
| 93 | - protected function _clearSubDiffs (): void { |
|
| 93 | + protected function _clearSubDiffs(): void { |
|
| 94 | 94 | // use isset() to avoid has() fetch. |
| 95 | 95 | if (isset($this->data['custom_fields'])) { |
| 96 | 96 | $this->getCustomFields()->diff = []; |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - final protected function _getDir (): string { |
|
| 103 | + final protected function _getDir(): string { |
|
| 104 | 104 | return 'tasks'; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - protected function _getMap (): array { |
|
| 107 | + protected function _getMap(): array { |
|
| 108 | 108 | return [ |
| 109 | 109 | 'assignee' => User::class, |
| 110 | 110 | 'custom_fields' => CustomValues::class, |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @param string $file |
| 126 | 126 | * @return Attachment |
| 127 | 127 | */ |
| 128 | - public function addAttachment (string $file) { |
|
| 128 | + public function addAttachment(string $file) { |
|
| 129 | 129 | /** @var Attachment $attachment */ |
| 130 | 130 | $attachment = $this->factory(Attachment::class, ['parent' => $this]); |
| 131 | 131 | return $attachment->upload($file); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param string $text |
| 138 | 138 | * @return Story |
| 139 | 139 | */ |
| 140 | - public function addComment (string $text) { |
|
| 140 | + public function addComment(string $text) { |
|
| 141 | 141 | return $this->newComment()->setText($text)->create(); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param Task[] $tasks |
| 149 | 149 | * @return $this |
| 150 | 150 | */ |
| 151 | - public function addDependencies (array $tasks) { |
|
| 151 | + public function addDependencies(array $tasks) { |
|
| 152 | 152 | $this->api->post("{$this}/addDependencies", ['dependents' => static::_getGids($tasks)]); |
| 153 | 153 | return $this; |
| 154 | 154 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @param Task $task |
| 161 | 161 | * @return $this |
| 162 | 162 | */ |
| 163 | - public function addDependency (Task $task) { |
|
| 163 | + public function addDependency(Task $task) { |
|
| 164 | 164 | return $this->addDependencies([$task]); |
| 165 | 165 | } |
| 166 | 166 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param Task $task |
| 172 | 172 | * @return $this |
| 173 | 173 | */ |
| 174 | - public function addDependent (Task $task) { |
|
| 174 | + public function addDependent(Task $task) { |
|
| 175 | 175 | return $this->addDependents([$task]); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param Task[] $tasks |
| 183 | 183 | * @return $this |
| 184 | 184 | */ |
| 185 | - public function addDependents (array $tasks) { |
|
| 185 | + public function addDependents(array $tasks) { |
|
| 186 | 186 | $this->api->post("{$this}/addDependents", ['dependents' => static::_getGids($tasks)]); |
| 187 | 187 | return $this; |
| 188 | 188 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param User $user |
| 194 | 194 | * @return $this |
| 195 | 195 | */ |
| 196 | - public function addFollower (User $user) { |
|
| 196 | + public function addFollower(User $user) { |
|
| 197 | 197 | return $this->addFollowers([$user]); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @param User[] $users |
| 204 | 204 | * @return $this |
| 205 | 205 | */ |
| 206 | - public function addFollowers (array $users) { |
|
| 206 | + public function addFollowers(array $users) { |
|
| 207 | 207 | if ($this->hasGid()) { |
| 208 | 208 | $this->api->post("{$this}/addFollowers", ['followers' => static::_getGids($users)]); |
| 209 | 209 | $this->_merge('followers', $users); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @param Tag $tag |
| 221 | 221 | * @return $this |
| 222 | 222 | */ |
| 223 | - public function addTag (Tag $tag) { |
|
| 223 | + public function addTag(Tag $tag) { |
|
| 224 | 224 | if ($this->hasGid()) { |
| 225 | 225 | $this->api->post("{$this}/addTag", ['tag' => $tag->getGid()]); |
| 226 | 226 | $this->_merge('tags', [$tag]); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * @param Section $section |
| 238 | 238 | * @return $this |
| 239 | 239 | */ |
| 240 | - public function addToProject (Section $section) { |
|
| 240 | + public function addToProject(Section $section) { |
|
| 241 | 241 | $project = $section->getProject(); |
| 242 | 242 | if ($this->hasGid()) { |
| 243 | 243 | $this->api->post("{$this}/addProject", [ |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @param string $target |
| 272 | 272 | * @return TaskWebhook |
| 273 | 273 | */ |
| 274 | - public function addWebhook (string $target) { |
|
| 274 | + public function addWebhook(string $target) { |
|
| 275 | 275 | /** @var TaskWebhook $webhook */ |
| 276 | 276 | $webhook = $this->factory(TaskWebhook::class); |
| 277 | 277 | return $webhook->create($this, $target); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | /** |
| 281 | 281 | * @return $this |
| 282 | 282 | */ |
| 283 | - public function create () { |
|
| 283 | + public function create() { |
|
| 284 | 284 | $this->_create(); |
| 285 | 285 | $this->_clearSubDiffs(); |
| 286 | 286 | return $this; |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @param string[] $include |
| 297 | 297 | * @return Job |
| 298 | 298 | */ |
| 299 | - public function duplicate (string $name, array $include) { |
|
| 299 | + public function duplicate(string $name, array $include) { |
|
| 300 | 300 | $remote = $this->api->post("{$this}/duplicate", [ |
| 301 | 301 | 'name' => $name, |
| 302 | 302 | 'include' => array_values($include) |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * @depends after-create |
| 311 | 311 | * @return Attachment[] |
| 312 | 312 | */ |
| 313 | - public function getAttachments () { |
|
| 313 | + public function getAttachments() { |
|
| 314 | 314 | return $this->loadAll(Attachment::class, "{$this}/attachments"); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * @depends after-create |
| 321 | 321 | * @return Story[] |
| 322 | 322 | */ |
| 323 | - public function getComments () { |
|
| 323 | + public function getComments() { |
|
| 324 | 324 | return array_values(array_filter($this->getStories(), function(Story $story) { |
| 325 | 325 | return $story->isComment(); |
| 326 | 326 | })); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | * @depends after-create |
| 333 | 333 | * @return Task[] |
| 334 | 334 | */ |
| 335 | - public function getDependencies () { |
|
| 335 | + public function getDependencies() { |
|
| 336 | 336 | return $this->loadAll(self::class, "{$this}/dependencies"); |
| 337 | 337 | } |
| 338 | 338 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @depends after-create |
| 343 | 343 | * @return Task[] |
| 344 | 344 | */ |
| 345 | - public function getDependents () { |
|
| 345 | + public function getDependents() { |
|
| 346 | 346 | return $this->loadAll(self::class, "{$this}/dependents"); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -353,21 +353,21 @@ discard block |
||
| 353 | 353 | * @param null|string $token |
| 354 | 354 | * @return TaskEvent[]|StoryEvent[] |
| 355 | 355 | */ |
| 356 | - public function getEvents (&$token) { |
|
| 356 | + public function getEvents(&$token) { |
|
| 357 | 357 | return $this->api->sync($this, $token); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
| 361 | 361 | * @return External |
| 362 | 362 | */ |
| 363 | - public function getExternal () { |
|
| 363 | + public function getExternal() { |
|
| 364 | 364 | return $this->_get('external') ?? $this->data['external'] = $this->factory($this->_getMap()['external']); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
| 368 | 368 | * @return Project[] |
| 369 | 369 | */ |
| 370 | - public function getProjects () { |
|
| 370 | + public function getProjects() { |
|
| 371 | 371 | return array_map(function(Membership $membership) { |
| 372 | 372 | return $membership->getProject(); |
| 373 | 373 | }, $this->getMemberships()); |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | * @depends after-create |
| 380 | 380 | * @return Story[] |
| 381 | 381 | */ |
| 382 | - public function getStories () { |
|
| 382 | + public function getStories() { |
|
| 383 | 383 | return $this->loadAll(Story::class, "{$this}/stories"); |
| 384 | 384 | } |
| 385 | 385 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * @depends after-create |
| 390 | 390 | * @return Task[] |
| 391 | 391 | */ |
| 392 | - public function getSubTasks () { |
|
| 392 | + public function getSubTasks() { |
|
| 393 | 393 | return $this->loadAll(self::class, "{$this}/subtasks"); |
| 394 | 394 | } |
| 395 | 395 | |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | * @depends after-create |
| 400 | 400 | * @return string |
| 401 | 401 | */ |
| 402 | - public function getUrl (): string { |
|
| 402 | + public function getUrl(): string { |
|
| 403 | 403 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
| 404 | 404 | } |
| 405 | 405 | |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | * @depends after-create |
| 410 | 410 | * @return TaskWebhook[] |
| 411 | 411 | */ |
| 412 | - public function getWebhooks () { |
|
| 412 | + public function getWebhooks() { |
|
| 413 | 413 | return $this->loadAll(TaskWebhook::class, 'webhooks', [ |
| 414 | 414 | 'workspace' => $this->getWorkspace()->getGid(), |
| 415 | 415 | 'resource' => $this->getGid() |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | /** |
| 420 | 420 | * @return bool |
| 421 | 421 | */ |
| 422 | - public function isRenderedAsSeparator (): bool { |
|
| 422 | + public function isRenderedAsSeparator(): bool { |
|
| 423 | 423 | return $this->_is('is_rendered_as_separator'); |
| 424 | 424 | } |
| 425 | 425 | |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | * @depends after-create |
| 430 | 430 | * @return Story |
| 431 | 431 | */ |
| 432 | - public function newComment () { |
|
| 432 | + public function newComment() { |
|
| 433 | 433 | /** @var Story $comment */ |
| 434 | 434 | $comment = $this->factory(Story::class, [ |
| 435 | 435 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | * @depends after-create |
| 444 | 444 | * @return Task |
| 445 | 445 | */ |
| 446 | - public function newSubTask () { |
|
| 446 | + public function newSubTask() { |
|
| 447 | 447 | /** @var Task $sub */ |
| 448 | 448 | $sub = $this->factory(self::class); |
| 449 | 449 | return $sub->setParent($this); |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | * @param Task[] $tasks |
| 457 | 457 | * @return $this |
| 458 | 458 | */ |
| 459 | - public function removeDependencies (array $tasks) { |
|
| 459 | + public function removeDependencies(array $tasks) { |
|
| 460 | 460 | $this->api->post("{$this}/removeDependencies", ['dependencies' => static::_getGids($tasks)]); |
| 461 | 461 | return $this; |
| 462 | 462 | } |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | * @param Task $task |
| 469 | 469 | * @return $this |
| 470 | 470 | */ |
| 471 | - public function removeDependency (Task $task) { |
|
| 471 | + public function removeDependency(Task $task) { |
|
| 472 | 472 | return $this->removeDependencies([$task]); |
| 473 | 473 | } |
| 474 | 474 | |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | * @param Task $task |
| 480 | 480 | * @return $this |
| 481 | 481 | */ |
| 482 | - public function removeDependent (Task $task) { |
|
| 482 | + public function removeDependent(Task $task) { |
|
| 483 | 483 | return $this->removeDependents([$task]); |
| 484 | 484 | } |
| 485 | 485 | |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | * @param Task[] $tasks |
| 491 | 491 | * @return $this |
| 492 | 492 | */ |
| 493 | - public function removeDependents (array $tasks) { |
|
| 493 | + public function removeDependents(array $tasks) { |
|
| 494 | 494 | $this->api->post("{$this}/removeDependents", ['dependents' => static::_getGids($tasks)]); |
| 495 | 495 | return $this; |
| 496 | 496 | } |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | * @param User $user |
| 502 | 502 | * @return $this |
| 503 | 503 | */ |
| 504 | - public function removeFollower (User $user) { |
|
| 504 | + public function removeFollower(User $user) { |
|
| 505 | 505 | return $this->removeFollowers([$user]); |
| 506 | 506 | } |
| 507 | 507 | |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | * @param User[] $users |
| 512 | 512 | * @return $this |
| 513 | 513 | */ |
| 514 | - public function removeFollowers (array $users) { |
|
| 514 | + public function removeFollowers(array $users) { |
|
| 515 | 515 | if ($this->hasGid()) { |
| 516 | 516 | $this->api->post("{$this}/removeFollowers", ['followers' => static::_getGids($users)]); |
| 517 | 517 | } |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | * @param Project $project |
| 526 | 526 | * @return $this |
| 527 | 527 | */ |
| 528 | - public function removeFromProject (Project $project) { |
|
| 528 | + public function removeFromProject(Project $project) { |
|
| 529 | 529 | $gid = $project->getGid(); |
| 530 | 530 | if ($this->hasGid()) { |
| 531 | 531 | $this->api->post("{$this}/removeProject", ['project' => $gid]); |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | * @param Tag $tag |
| 545 | 545 | * @return $this |
| 546 | 546 | */ |
| 547 | - public function removeTag (Tag $tag) { |
|
| 547 | + public function removeTag(Tag $tag) { |
|
| 548 | 548 | if ($this->hasGid()) { |
| 549 | 549 | $this->api->post("{$this}/removeTag", ['tag' => $tag->getGid()]); |
| 550 | 550 | } |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | * @param null|Task $parent |
| 559 | 559 | * @return $this |
| 560 | 560 | */ |
| 561 | - public function setParent (?self $parent) { |
|
| 561 | + public function setParent(?self $parent) { |
|
| 562 | 562 | if ($this->hasGid()) { |
| 563 | 563 | $this->api->post("{$this}/setParent", ['parent' => $parent ? $parent->getGid() : null]); |
| 564 | 564 | $this->data['parent'] = $parent; |
@@ -573,14 +573,14 @@ discard block |
||
| 573 | 573 | * @param bool $flag |
| 574 | 574 | * @return $this |
| 575 | 575 | */ |
| 576 | - public function setRenderedAsSeparator (bool $flag) { |
|
| 576 | + public function setRenderedAsSeparator(bool $flag) { |
|
| 577 | 577 | return $this->_set('is_rendered_as_separator', $flag); |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | /** |
| 581 | 581 | * @return $this |
| 582 | 582 | */ |
| 583 | - public function update () { |
|
| 583 | + public function update() { |
|
| 584 | 584 | $this->_update(); |
| 585 | 585 | $this->_clearSubDiffs(); |
| 586 | 586 | return $this; |