@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | protected $task; |
| 26 | 26 | |
| 27 | - public function __construct (Task $task, array $data = []) { |
|
| 27 | + public function __construct(Task $task, array $data = []) { |
|
| 28 | 28 | parent::__construct($task, $data); |
| 29 | 29 | $this->task = $task; |
| 30 | 30 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param mixed $value |
| 37 | 37 | * @return $this |
| 38 | 38 | */ |
| 39 | - protected function _set (string $key, $value) { |
|
| 39 | + protected function _set(string $key, $value) { |
|
| 40 | 40 | $this->task->diff['external'] = true; |
| 41 | 41 | return parent::_set($key, $value); |
| 42 | 42 | } |
@@ -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 | * Resolves entities to GIDs. |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @param AbstractEntity[] $entities |
| 25 | 25 | * @return string[] |
| 26 | 26 | */ |
| 27 | - protected static function _getGids (array $entities) { |
|
| 27 | + protected static function _getGids(array $entities) { |
|
| 28 | 28 | return array_map(function(AbstractEntity $entity) { |
| 29 | 29 | return $entity->getGid(); |
| 30 | 30 | }, $entities); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param string $key |
| 37 | 37 | * @return mixed |
| 38 | 38 | */ |
| 39 | - protected function _get (string $key) { |
|
| 39 | + protected function _get(string $key) { |
|
| 40 | 40 | if (!array_key_exists($key, $this->data) and isset($this->data['gid'])) { // can't use hasGid(), inf. loop |
| 41 | 41 | $this->reload($key); |
| 42 | 42 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param bool $force |
| 52 | 52 | * @return $this |
| 53 | 53 | */ |
| 54 | - protected function _merge (string $key, array $entities, $force = false) { |
|
| 54 | + protected function _merge(string $key, array $entities, $force = false) { |
|
| 55 | 55 | if ($force or isset($this->data[$key])) { |
| 56 | 56 | foreach ($entities as $entity) { |
| 57 | 57 | $this->data[$key][] = $entity; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param AbstractEntity[] $entities |
| 75 | 75 | * @return $this |
| 76 | 76 | */ |
| 77 | - protected function _remove (string $key, array $entities) { |
|
| 77 | + protected function _remove(string $key, array $entities) { |
|
| 78 | 78 | if (isset($this->data[$key])) { |
| 79 | 79 | $this->data[$key] = array_values(array_diff($this->data[$key], $entities)); |
| 80 | 80 | $this->api->getCache()->add($this); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param AbstractEntity $entity |
| 89 | 89 | * @return $this |
| 90 | 90 | */ |
| 91 | - public function merge (AbstractEntity $entity) { |
|
| 91 | + public function merge(AbstractEntity $entity) { |
|
| 92 | 92 | assert($entity->api); // hydrated |
| 93 | 93 | foreach ($entity->data as $key => $value) { |
| 94 | 94 | if (!array_key_exists($key, $this->data) and !isset($entity->diff[$key])) { |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @param string $key |
| 105 | 105 | * @return $this |
| 106 | 106 | */ |
| 107 | - public function reload (string $key = null) { |
|
| 107 | + public function reload(string $key = null) { |
|
| 108 | 108 | if (isset($key)) { |
| 109 | 109 | $value = $this->api->get($this, [], ['fields' => $key])[$key] ?? null; |
| 110 | 110 | $map = $this->_getMap(); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | const ASSIGN_TODAY = 'today'; |
| 80 | 80 | const ASSIGN_UPCOMING = 'upcoming'; |
| 81 | 81 | |
| 82 | - public function __construct ($caller, array $data = []) { |
|
| 82 | + public function __construct($caller, array $data = []) { |
|
| 83 | 83 | parent::__construct($caller, $data); |
| 84 | 84 | |
| 85 | 85 | // Asana has a bug where it returns empty memberships when expanding "this". |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - final public function __toString (): string { |
|
| 97 | + final public function __toString(): string { |
|
| 98 | 98 | return "tasks/{$this->getGid()}"; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Clears the diffs for `custom_fields` and `external` sub-objects after saving. |
| 103 | 103 | */ |
| 104 | - protected function _clearSubDiffs (): void { |
|
| 104 | + protected function _clearSubDiffs(): void { |
|
| 105 | 105 | // use isset() to avoid has() fetch. |
| 106 | 106 | if (isset($this->data['custom_fields'])) { |
| 107 | 107 | $this->getCustomFields()->diff = []; |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - final protected function _getDir (): string { |
|
| 114 | + final protected function _getDir(): string { |
|
| 115 | 115 | return 'tasks'; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - protected function _getMap (): array { |
|
| 118 | + protected function _getMap(): array { |
|
| 119 | 119 | return [ |
| 120 | 120 | 'assignee' => User::class, |
| 121 | 121 | 'custom_fields' => CustomValues::class, |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @param string $file |
| 137 | 137 | * @return Attachment |
| 138 | 138 | */ |
| 139 | - public function addAttachment (string $file) { |
|
| 139 | + public function addAttachment(string $file) { |
|
| 140 | 140 | /** @var Attachment $attachment */ |
| 141 | 141 | $attachment = $this->factory(Attachment::class, ['parent' => $this]); |
| 142 | 142 | return $attachment->upload($file); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param string $text |
| 149 | 149 | * @return Story |
| 150 | 150 | */ |
| 151 | - public function addComment (string $text) { |
|
| 151 | + public function addComment(string $text) { |
|
| 152 | 152 | return $this->newComment()->setText($text)->create(); |
| 153 | 153 | } |
| 154 | 154 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param Task[] $tasks |
| 160 | 160 | * @return $this |
| 161 | 161 | */ |
| 162 | - public function addDependencies (array $tasks) { |
|
| 162 | + public function addDependencies(array $tasks) { |
|
| 163 | 163 | $this->api->post("{$this}/addDependencies", ['dependents' => static::_getGids($tasks)]); |
| 164 | 164 | return $this; |
| 165 | 165 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param Task $task |
| 172 | 172 | * @return $this |
| 173 | 173 | */ |
| 174 | - public function addDependency (Task $task) { |
|
| 174 | + public function addDependency(Task $task) { |
|
| 175 | 175 | return $this->addDependencies([$task]); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param Task $task |
| 183 | 183 | * @return $this |
| 184 | 184 | */ |
| 185 | - public function addDependent (Task $task) { |
|
| 185 | + public function addDependent(Task $task) { |
|
| 186 | 186 | return $this->addDependents([$task]); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param Task[] $tasks |
| 194 | 194 | * @return $this |
| 195 | 195 | */ |
| 196 | - public function addDependents (array $tasks) { |
|
| 196 | + public function addDependents(array $tasks) { |
|
| 197 | 197 | $this->api->post("{$this}/addDependents", ['dependents' => static::_getGids($tasks)]); |
| 198 | 198 | return $this; |
| 199 | 199 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @param User $user |
| 205 | 205 | * @return $this |
| 206 | 206 | */ |
| 207 | - public function addFollower (User $user) { |
|
| 207 | + public function addFollower(User $user) { |
|
| 208 | 208 | return $this->addFollowers([$user]); |
| 209 | 209 | } |
| 210 | 210 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param User[] $users |
| 215 | 215 | * @return $this |
| 216 | 216 | */ |
| 217 | - public function addFollowers (array $users) { |
|
| 217 | + public function addFollowers(array $users) { |
|
| 218 | 218 | if ($this->hasGid()) { |
| 219 | 219 | $this->api->post("{$this}/addFollowers", ['followers' => static::_getGids($users)]); |
| 220 | 220 | $this->_merge('followers', $users); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param Tag $tag |
| 232 | 232 | * @return $this |
| 233 | 233 | */ |
| 234 | - public function addTag (Tag $tag) { |
|
| 234 | + public function addTag(Tag $tag) { |
|
| 235 | 235 | if ($this->hasGid()) { |
| 236 | 236 | $this->api->post("{$this}/addTag", ['tag' => $tag->getGid()]); |
| 237 | 237 | $this->_merge('tags', [$tag]); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * @param Section $section |
| 249 | 249 | * @return $this |
| 250 | 250 | */ |
| 251 | - public function addToProject (Section $section) { |
|
| 251 | + public function addToProject(Section $section) { |
|
| 252 | 252 | $project = $section->getProject(); |
| 253 | 253 | if ($this->hasGid()) { |
| 254 | 254 | $this->api->post("{$this}/addProject", [ |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @param string $target |
| 283 | 283 | * @return TaskWebhook |
| 284 | 284 | */ |
| 285 | - public function addWebhook (string $target) { |
|
| 285 | + public function addWebhook(string $target) { |
|
| 286 | 286 | /** @var TaskWebhook $webhook */ |
| 287 | 287 | $webhook = $this->factory(TaskWebhook::class); |
| 288 | 288 | return $webhook->create($this, $target); |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | /** |
| 292 | 292 | * @return $this |
| 293 | 293 | */ |
| 294 | - public function create () { |
|
| 294 | + public function create() { |
|
| 295 | 295 | $this->_create(); |
| 296 | 296 | $this->_clearSubDiffs(); |
| 297 | 297 | return $this; |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | * @param string[] $include |
| 308 | 308 | * @return Job |
| 309 | 309 | */ |
| 310 | - public function duplicate (string $name, array $include) { |
|
| 310 | + public function duplicate(string $name, array $include) { |
|
| 311 | 311 | $remote = $this->api->post("{$this}/duplicate", [ |
| 312 | 312 | 'name' => $name, |
| 313 | 313 | 'include' => array_values($include) |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @depends after-create |
| 322 | 322 | * @return Attachment[] |
| 323 | 323 | */ |
| 324 | - public function getAttachments () { |
|
| 324 | + public function getAttachments() { |
|
| 325 | 325 | return $this->loadAll(Attachment::class, "{$this}/attachments"); |
| 326 | 326 | } |
| 327 | 327 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @depends after-create |
| 332 | 332 | * @return Story[] |
| 333 | 333 | */ |
| 334 | - public function getComments () { |
|
| 334 | + public function getComments() { |
|
| 335 | 335 | return array_values(array_filter($this->getStories(), function(Story $story) { |
| 336 | 336 | return $story->isComment(); |
| 337 | 337 | })); |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @depends after-create |
| 344 | 344 | * @return Task[] |
| 345 | 345 | */ |
| 346 | - public function getDependencies () { |
|
| 346 | + public function getDependencies() { |
|
| 347 | 347 | return $this->loadAll(self::class, "{$this}/dependencies"); |
| 348 | 348 | } |
| 349 | 349 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @depends after-create |
| 354 | 354 | * @return Task[] |
| 355 | 355 | */ |
| 356 | - public function getDependents () { |
|
| 356 | + public function getDependents() { |
|
| 357 | 357 | return $this->loadAll(self::class, "{$this}/dependents"); |
| 358 | 358 | } |
| 359 | 359 | |
@@ -364,21 +364,21 @@ discard block |
||
| 364 | 364 | * @param null|string $token |
| 365 | 365 | * @return TaskEvent[]|StoryEvent[] |
| 366 | 366 | */ |
| 367 | - public function getEvents (&$token) { |
|
| 367 | + public function getEvents(&$token) { |
|
| 368 | 368 | return $this->api->sync($this, $token); |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
| 372 | 372 | * @return External |
| 373 | 373 | */ |
| 374 | - public function getExternal () { |
|
| 374 | + public function getExternal() { |
|
| 375 | 375 | return $this->_get('external') ?? $this->data['external'] = $this->factory($this->_getMap()['external']); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | /** |
| 379 | 379 | * @return Project[] |
| 380 | 380 | */ |
| 381 | - public function getProjects () { |
|
| 381 | + public function getProjects() { |
|
| 382 | 382 | return array_map(function(Membership $membership) { |
| 383 | 383 | return $membership->getProject(); |
| 384 | 384 | }, $this->getMemberships()); |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * @depends after-create |
| 391 | 391 | * @return Story[] |
| 392 | 392 | */ |
| 393 | - public function getStories () { |
|
| 393 | + public function getStories() { |
|
| 394 | 394 | return $this->loadAll(Story::class, "{$this}/stories"); |
| 395 | 395 | } |
| 396 | 396 | |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | * @depends after-create |
| 401 | 401 | * @return Task[] |
| 402 | 402 | */ |
| 403 | - public function getSubTasks () { |
|
| 403 | + public function getSubTasks() { |
|
| 404 | 404 | return $this->loadAll(self::class, "{$this}/subtasks"); |
| 405 | 405 | } |
| 406 | 406 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | * @depends after-create |
| 411 | 411 | * @return string |
| 412 | 412 | */ |
| 413 | - public function getUrl (): string { |
|
| 413 | + public function getUrl(): string { |
|
| 414 | 414 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
| 415 | 415 | } |
| 416 | 416 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | * @depends after-create |
| 421 | 421 | * @return TaskWebhook[] |
| 422 | 422 | */ |
| 423 | - public function getWebhooks () { |
|
| 423 | + public function getWebhooks() { |
|
| 424 | 424 | return $this->loadAll(TaskWebhook::class, 'webhooks', [ |
| 425 | 425 | 'workspace' => $this->getWorkspace()->getGid(), |
| 426 | 426 | 'resource' => $this->getGid() |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | /** |
| 431 | 431 | * @return bool |
| 432 | 432 | */ |
| 433 | - public function isRenderedAsSeparator (): bool { |
|
| 433 | + public function isRenderedAsSeparator(): bool { |
|
| 434 | 434 | return $this->_is('is_rendered_as_separator'); |
| 435 | 435 | } |
| 436 | 436 | |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | * @depends after-create |
| 441 | 441 | * @return Story |
| 442 | 442 | */ |
| 443 | - public function newComment () { |
|
| 443 | + public function newComment() { |
|
| 444 | 444 | /** @var Story $comment */ |
| 445 | 445 | $comment = $this->factory(Story::class, [ |
| 446 | 446 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | * @depends after-create |
| 455 | 455 | * @return Task |
| 456 | 456 | */ |
| 457 | - public function newSubTask () { |
|
| 457 | + public function newSubTask() { |
|
| 458 | 458 | /** @var Task $sub */ |
| 459 | 459 | $sub = $this->factory(self::class); |
| 460 | 460 | return $sub->setParent($this); |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | * @param Task[] $tasks |
| 468 | 468 | * @return $this |
| 469 | 469 | */ |
| 470 | - public function removeDependencies (array $tasks) { |
|
| 470 | + public function removeDependencies(array $tasks) { |
|
| 471 | 471 | $this->api->post("{$this}/removeDependencies", ['dependencies' => static::_getGids($tasks)]); |
| 472 | 472 | return $this; |
| 473 | 473 | } |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | * @param Task $task |
| 480 | 480 | * @return $this |
| 481 | 481 | */ |
| 482 | - public function removeDependency (Task $task) { |
|
| 482 | + public function removeDependency(Task $task) { |
|
| 483 | 483 | return $this->removeDependencies([$task]); |
| 484 | 484 | } |
| 485 | 485 | |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | * @param Task $task |
| 491 | 491 | * @return $this |
| 492 | 492 | */ |
| 493 | - public function removeDependent (Task $task) { |
|
| 493 | + public function removeDependent(Task $task) { |
|
| 494 | 494 | return $this->removeDependents([$task]); |
| 495 | 495 | } |
| 496 | 496 | |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | * @param Task[] $tasks |
| 502 | 502 | * @return $this |
| 503 | 503 | */ |
| 504 | - public function removeDependents (array $tasks) { |
|
| 504 | + public function removeDependents(array $tasks) { |
|
| 505 | 505 | $this->api->post("{$this}/removeDependents", ['dependents' => static::_getGids($tasks)]); |
| 506 | 506 | return $this; |
| 507 | 507 | } |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | * @param User $user |
| 513 | 513 | * @return $this |
| 514 | 514 | */ |
| 515 | - public function removeFollower (User $user) { |
|
| 515 | + public function removeFollower(User $user) { |
|
| 516 | 516 | return $this->removeFollowers([$user]); |
| 517 | 517 | } |
| 518 | 518 | |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | * @param User[] $users |
| 523 | 523 | * @return $this |
| 524 | 524 | */ |
| 525 | - public function removeFollowers (array $users) { |
|
| 525 | + public function removeFollowers(array $users) { |
|
| 526 | 526 | if ($this->hasGid()) { |
| 527 | 527 | $this->api->post("{$this}/removeFollowers", ['followers' => static::_getGids($users)]); |
| 528 | 528 | } |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | * @param Project $project |
| 537 | 537 | * @return $this |
| 538 | 538 | */ |
| 539 | - public function removeFromProject (Project $project) { |
|
| 539 | + public function removeFromProject(Project $project) { |
|
| 540 | 540 | $gid = $project->getGid(); |
| 541 | 541 | if ($this->hasGid()) { |
| 542 | 542 | $this->api->post("{$this}/removeProject", ['project' => $gid]); |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | * @param Tag $tag |
| 556 | 556 | * @return $this |
| 557 | 557 | */ |
| 558 | - public function removeTag (Tag $tag) { |
|
| 558 | + public function removeTag(Tag $tag) { |
|
| 559 | 559 | if ($this->hasGid()) { |
| 560 | 560 | $this->api->post("{$this}/removeTag", ['tag' => $tag->getGid()]); |
| 561 | 561 | } |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | * @param null|Task $parent |
| 570 | 570 | * @return $this |
| 571 | 571 | */ |
| 572 | - public function setParent (?self $parent) { |
|
| 572 | + public function setParent(?self $parent) { |
|
| 573 | 573 | if ($this->hasGid()) { |
| 574 | 574 | $this->api->post("{$this}/setParent", ['parent' => $parent ? $parent->getGid() : null]); |
| 575 | 575 | $this->data['parent'] = $parent; |
@@ -584,14 +584,14 @@ discard block |
||
| 584 | 584 | * @param bool $flag |
| 585 | 585 | * @return $this |
| 586 | 586 | */ |
| 587 | - public function setRenderedAsSeparator (bool $flag) { |
|
| 587 | + public function setRenderedAsSeparator(bool $flag) { |
|
| 588 | 588 | return $this->_set('is_rendered_as_separator', $flag); |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | /** |
| 592 | 592 | * @return $this |
| 593 | 593 | */ |
| 594 | - public function update () { |
|
| 594 | + public function update() { |
|
| 595 | 595 | $this->_update(); |
| 596 | 596 | $this->_clearSubDiffs(); |
| 597 | 597 | return $this; |