@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | 'memberships' => 'memberships.(project|section)' |
| 122 | 122 | ]; |
| 123 | 123 | |
| 124 | - private function _onSave (): void { |
|
| 124 | + private function _onSave(): void { |
|
| 125 | 125 | /** @var FieldEntries $fields */ |
| 126 | 126 | if ($fields = $this->data['custom_fields'] ?? null) { |
| 127 | 127 | $fields->__unset(true); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - protected function _setData (array $data): void { |
|
| 135 | + protected function _setData(array $data): void { |
|
| 136 | 136 | // hearts were deprecated for likes. |
| 137 | 137 | unset($data['hearted'], $data['hearts'], $data['num_hearts']); |
| 138 | 138 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @param string $file |
| 152 | 152 | * @return Attachment |
| 153 | 153 | */ |
| 154 | - public function addAttachment (string $file) { |
|
| 154 | + public function addAttachment(string $file) { |
|
| 155 | 155 | /** @var Attachment $attachment */ |
| 156 | 156 | $attachment = $this->api->factory($this, Attachment::class, ['parent' => $this]); |
| 157 | 157 | return $attachment->create($file); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param Task[] $tasks |
| 164 | 164 | * @return $this |
| 165 | 165 | */ |
| 166 | - public function addDependencies (array $tasks) { |
|
| 166 | + public function addDependencies(array $tasks) { |
|
| 167 | 167 | $this->api->post("{$this}/addDependencies", ['dependents' => array_column($tasks, 'gid')]); |
| 168 | 168 | return $this; |
| 169 | 169 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * @param Task $task |
| 175 | 175 | * @return $this |
| 176 | 176 | */ |
| 177 | - public function addDependency (Task $task) { |
|
| 177 | + public function addDependency(Task $task) { |
|
| 178 | 178 | return $this->addDependencies([$task]); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @param Task $task |
| 185 | 185 | * @return $this |
| 186 | 186 | */ |
| 187 | - public function addDependent (Task $task) { |
|
| 187 | + public function addDependent(Task $task) { |
|
| 188 | 188 | return $this->addDependents([$task]); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @param Task[] $tasks |
| 195 | 195 | * @return $this |
| 196 | 196 | */ |
| 197 | - public function addDependents (array $tasks) { |
|
| 197 | + public function addDependents(array $tasks) { |
|
| 198 | 198 | $this->api->post("{$this}/addDependents", ['dependents' => array_column($tasks, 'gid')]); |
| 199 | 199 | return $this; |
| 200 | 200 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @param User $user |
| 206 | 206 | * @return $this |
| 207 | 207 | */ |
| 208 | - public function addFollower (User $user) { |
|
| 208 | + public function addFollower(User $user) { |
|
| 209 | 209 | return $this->addFollowers([$user]); |
| 210 | 210 | } |
| 211 | 211 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param User[] $users |
| 218 | 218 | * @return $this |
| 219 | 219 | */ |
| 220 | - public function addFollowers (array $users) { |
|
| 220 | + public function addFollowers(array $users) { |
|
| 221 | 221 | return $this->_addWithPost("{$this}/addFollowers", [ |
| 222 | 222 | 'followers' => array_column($users, 'gid') |
| 223 | 223 | ], '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 | assert($tag->hasGid()); |
| 236 | 236 | return $this->_addWithPost("{$this}/addTag", [ |
| 237 | 237 | 'tag' => $tag->getGid() |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @param Project|Section $target |
| 250 | 250 | * @return $this |
| 251 | 251 | */ |
| 252 | - public function addToProject ($target) { |
|
| 252 | + public function addToProject($target) { |
|
| 253 | 253 | assert($target->hasGid()); |
| 254 | 254 | if ($target instanceof Project) { |
| 255 | 255 | $target = $target->getDefaultSection(); |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | /** |
| 264 | 264 | * @return $this |
| 265 | 265 | */ |
| 266 | - public function create () { |
|
| 266 | + public function create() { |
|
| 267 | 267 | $this->_create(); |
| 268 | 268 | $this->_onSave(); |
| 269 | 269 | return $this; |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @param string[] $include |
| 279 | 279 | * @return Job |
| 280 | 280 | */ |
| 281 | - public function duplicate (string $name, array $include) { |
|
| 281 | + public function duplicate(string $name, array $include) { |
|
| 282 | 282 | /** @var array $remote */ |
| 283 | 283 | $remote = $this->api->post("{$this}/duplicate", [ |
| 284 | 284 | 'name' => $name, |
@@ -292,14 +292,14 @@ discard block |
||
| 292 | 292 | * |
| 293 | 293 | * @return Attachment[] |
| 294 | 294 | */ |
| 295 | - public function getAttachments () { |
|
| 295 | + public function getAttachments() { |
|
| 296 | 296 | return $this->api->loadAll($this, Attachment::class, "{$this}/attachments"); |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
| 300 | 300 | * @return Story[] |
| 301 | 301 | */ |
| 302 | - public function getComments () { |
|
| 302 | + public function getComments() { |
|
| 303 | 303 | return $this->selectStories(function(Story $story) { |
| 304 | 304 | return $story->isComment(); |
| 305 | 305 | }); |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * |
| 311 | 311 | * @return Task[] |
| 312 | 312 | */ |
| 313 | - public function getDependencies () { |
|
| 313 | + public function getDependencies() { |
|
| 314 | 314 | return $this->api->loadAll($this, self::class, "{$this}/dependencies"); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * |
| 320 | 320 | * @return Task[] |
| 321 | 321 | */ |
| 322 | - public function getDependents () { |
|
| 322 | + public function getDependents() { |
|
| 323 | 323 | return $this->api->loadAll($this, self::class, "{$this}/dependents"); |
| 324 | 324 | } |
| 325 | 325 | |
@@ -334,49 +334,49 @@ discard block |
||
| 334 | 334 | * |
| 335 | 335 | * @return ExternalData |
| 336 | 336 | */ |
| 337 | - public function getExternal () { |
|
| 337 | + public function getExternal() { |
|
| 338 | 338 | return $this->_get('external') ?? $this->data['external'] = $this->api->factory($this, ExternalData::class); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
| 342 | 342 | * @return Project[] |
| 343 | 343 | */ |
| 344 | - public function getProjects () { |
|
| 344 | + public function getProjects() { |
|
| 345 | 345 | return array_column($this->getMemberships(), 'project'); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
| 349 | 349 | * @return Section[] |
| 350 | 350 | */ |
| 351 | - public function getSections () { |
|
| 351 | + public function getSections() { |
|
| 352 | 352 | return array_column($this->getMemberships(), 'section'); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | /** |
| 356 | 356 | * @return Story[] |
| 357 | 357 | */ |
| 358 | - public function getStories () { |
|
| 358 | + public function getStories() { |
|
| 359 | 359 | return $this->api->loadAll($this, Story::class, "{$this}/stories"); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
| 363 | 363 | * @return Task[] |
| 364 | 364 | */ |
| 365 | - public function getSubTasks () { |
|
| 365 | + public function getSubTasks() { |
|
| 366 | 366 | return $this->api->loadAll($this, self::class, "{$this}/subtasks"); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
| 370 | 370 | * @return string |
| 371 | 371 | */ |
| 372 | - final public function getUrl (): string { |
|
| 372 | + final public function getUrl(): string { |
|
| 373 | 373 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
| 377 | 377 | * @return TaskWebhook[] |
| 378 | 378 | */ |
| 379 | - public function getWebhooks () { |
|
| 379 | + public function getWebhooks() { |
|
| 380 | 380 | return $this->api->loadAll($this, TaskWebhook::class, 'webhooks', [ |
| 381 | 381 | 'workspace' => $this->getWorkspace()->getGid(), |
| 382 | 382 | 'resource' => $this->getGid() |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * |
| 389 | 389 | * @return Story |
| 390 | 390 | */ |
| 391 | - public function newComment () { |
|
| 391 | + public function newComment() { |
|
| 392 | 392 | return $this->api->factory($this, Story::class, [ |
| 393 | 393 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED, |
| 394 | 394 | 'target' => $this |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | * |
| 401 | 401 | * @return Task |
| 402 | 402 | */ |
| 403 | - public function newSubTask () { |
|
| 403 | + public function newSubTask() { |
|
| 404 | 404 | /** @var Task $sub */ |
| 405 | 405 | $sub = $this->api->factory($this, self::class); |
| 406 | 406 | return $sub->setParent($this); |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @return TaskWebhook |
| 413 | 413 | */ |
| 414 | - public function newWebhook () { |
|
| 414 | + public function newWebhook() { |
|
| 415 | 415 | /** @var TaskWebhook $webhook */ |
| 416 | 416 | $webhook = $this->api->factory($this, TaskWebhook::class); |
| 417 | 417 | return $webhook->setResource($this); |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | * @param Task[] $tasks |
| 424 | 424 | * @return $this |
| 425 | 425 | */ |
| 426 | - public function removeDependencies (array $tasks) { |
|
| 426 | + public function removeDependencies(array $tasks) { |
|
| 427 | 427 | $this->api->post("{$this}/removeDependencies", ['dependencies' => array_column($tasks, 'gid')]); |
| 428 | 428 | return $this; |
| 429 | 429 | } |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @param Task $task |
| 435 | 435 | * @return $this |
| 436 | 436 | */ |
| 437 | - public function removeDependency (Task $task) { |
|
| 437 | + public function removeDependency(Task $task) { |
|
| 438 | 438 | return $this->removeDependencies([$task]); |
| 439 | 439 | } |
| 440 | 440 | |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | * @param Task $task |
| 445 | 445 | * @return $this |
| 446 | 446 | */ |
| 447 | - public function removeDependent (Task $task) { |
|
| 447 | + public function removeDependent(Task $task) { |
|
| 448 | 448 | return $this->removeDependents([$task]); |
| 449 | 449 | } |
| 450 | 450 | |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | * @param Task[] $tasks |
| 455 | 455 | * @return $this |
| 456 | 456 | */ |
| 457 | - public function removeDependents (array $tasks) { |
|
| 457 | + public function removeDependents(array $tasks) { |
|
| 458 | 458 | $this->api->post("{$this}/removeDependents", ['dependents' => array_column($tasks, 'gid')]); |
| 459 | 459 | return $this; |
| 460 | 460 | } |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | * @param User $user |
| 466 | 466 | * @return $this |
| 467 | 467 | */ |
| 468 | - public function removeFollower (User $user) { |
|
| 468 | + public function removeFollower(User $user) { |
|
| 469 | 469 | return $this->removeFollowers([$user]); |
| 470 | 470 | } |
| 471 | 471 | |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | * @param User[] $users |
| 478 | 478 | * @return $this |
| 479 | 479 | */ |
| 480 | - public function removeFollowers (array $users) { |
|
| 480 | + public function removeFollowers(array $users) { |
|
| 481 | 481 | return $this->_removeWithPost("{$this}/removeFollowers", [ |
| 482 | 482 | 'followers' => array_column($users, 'gid') |
| 483 | 483 | ], 'followers', $users); |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * @param Project $project |
| 492 | 492 | * @return $this |
| 493 | 493 | */ |
| 494 | - public function removeFromProject (Project $project) { |
|
| 494 | + public function removeFromProject(Project $project) { |
|
| 495 | 495 | return $this->_removeWithPost("{$this}/removeProject", [ |
| 496 | 496 | 'project' => $project->getGid() |
| 497 | 497 | ], 'memberships', function(Membership $membership) use ($project) { |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | * @param Tag $tag |
| 508 | 508 | * @return $this |
| 509 | 509 | */ |
| 510 | - public function removeTag (Tag $tag) { |
|
| 510 | + public function removeTag(Tag $tag) { |
|
| 511 | 511 | return $this->_removeWithPost("{$this}/removeTag", [ |
| 512 | 512 | 'tag' => $tag->getGid() |
| 513 | 513 | ], 'tags', [$tag]); |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | * @param null|Task $parent |
| 521 | 521 | * @return $this |
| 522 | 522 | */ |
| 523 | - final public function setParent (?Task $parent) { |
|
| 523 | + final public function setParent(?Task $parent) { |
|
| 524 | 524 | assert($parent->hasGid()); |
| 525 | 525 | return $this->_setWithPost("{$this}/setParent", [ |
| 526 | 526 | 'parent' => $parent |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | /** |
| 531 | 531 | * @return $this |
| 532 | 532 | */ |
| 533 | - public function update () { |
|
| 533 | + public function update() { |
|
| 534 | 534 | $this->_update(); |
| 535 | 535 | $this->_onSave(); |
| 536 | 536 | return $this; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @return bool |
| 36 | 36 | * @internal pool |
| 37 | 37 | */ |
| 38 | - final public function __merge (self $entity): bool { |
|
| 38 | + final public function __merge(self $entity): bool { |
|
| 39 | 39 | $old = $this->toArray(); |
| 40 | 40 | $this->data = array_merge($this->data, array_diff_key($entity->data, $this->diff)); |
| 41 | 41 | return $this->toArray() !== $old; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return string |
| 48 | 48 | */ |
| 49 | - final public function __toString (): string { |
|
| 49 | + final public function __toString(): string { |
|
| 50 | 50 | return static::DIR . '/' . $this->getGid(); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param string $field |
| 57 | 57 | * @return mixed |
| 58 | 58 | */ |
| 59 | - protected function _get (string $field) { |
|
| 59 | + protected function _get(string $field) { |
|
| 60 | 60 | if (!array_key_exists($field, $this->data) and $this->hasGid()) { |
| 61 | 61 | $this->_reload($field); |
| 62 | 62 | } |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * @param string $field |
| 68 | 68 | */ |
| 69 | - protected function _reload (string $field): void { |
|
| 69 | + protected function _reload(string $field): void { |
|
| 70 | 70 | assert($this->hasGid()); |
| 71 | 71 | $remote = $this->api->get($this, ['opt_fields' => static::OPT_FIELDS[$field] ?? $field]); |
| 72 | 72 | $this->_setField($field, $remote[$field]); |
| 73 | 73 | $this->api->getPool()->add($this); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - protected function _setData (array $data): void { |
|
| 76 | + protected function _setData(array $data): void { |
|
| 77 | 77 | // meaningless once the entity is being created. it's constant. |
| 78 | 78 | unset($data['resource_type'], $data['type']); |
| 79 | 79 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * @return null|string |
| 85 | 85 | */ |
| 86 | - final public function getGid (): ?string { |
|
| 86 | + final public function getGid(): ?string { |
|
| 87 | 87 | return $this->data['gid'] ?? null; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return string[] |
| 94 | 94 | */ |
| 95 | - public function getPoolKeys () { |
|
| 95 | + public function getPoolKeys() { |
|
| 96 | 96 | return [$this->getGid(), (string)$this]; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return string |
| 103 | 103 | */ |
| 104 | - final public function getResourceType (): string { |
|
| 104 | + final public function getResourceType(): string { |
|
| 105 | 105 | return static::TYPE; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * @return bool |
| 110 | 110 | */ |
| 111 | - final public function hasGid (): bool { |
|
| 111 | + final public function hasGid(): bool { |
|
| 112 | 112 | return isset($this->data['gid']); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @return $this |
| 119 | 119 | */ |
| 120 | - public function reload () { |
|
| 120 | + public function reload() { |
|
| 121 | 121 | assert($this->hasGid()); |
| 122 | 122 | $remote = $this->api->get($this, ['opt_expand' => 'this']); |
| 123 | 123 | if (!isset($remote['gid'])) { // deleted? |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | * |
| 24 | 24 | * @return $this |
| 25 | 25 | */ |
| 26 | - public function create () { |
|
| 26 | + public function create() { |
|
| 27 | 27 | assert(!$this->hasGid()); |
| 28 | 28 | $path = static::DIR; |
| 29 | 29 | if (isset($this->parent)) { |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | private $defaultSection; |
| 97 | 97 | |
| 98 | - protected function _setData (array $data): void { |
|
| 98 | + protected function _setData(array $data): void { |
|
| 99 | 99 | // this is always empty. fields are in the settings, values are in tasks. |
| 100 | 100 | unset($data['custom_fields']); |
| 101 | 101 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @param User $user |
| 110 | 110 | * @return $this |
| 111 | 111 | */ |
| 112 | - public function addFollower (User $user) { |
|
| 112 | + public function addFollower(User $user) { |
|
| 113 | 113 | return $this->addFollowers([$user]); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @param User[] $users |
| 118 | 118 | * @return $this |
| 119 | 119 | */ |
| 120 | - public function addFollowers (array $users) { |
|
| 120 | + public function addFollowers(array $users) { |
|
| 121 | 121 | return $this->_addWithPost("{$this}/addFollowers", [ |
| 122 | 122 | 'followers' => array_column($users, 'gid') |
| 123 | 123 | ], 'followers', $users); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param User $user |
| 128 | 128 | * @return $this |
| 129 | 129 | */ |
| 130 | - public function addMember (User $user) { |
|
| 130 | + public function addMember(User $user) { |
|
| 131 | 131 | return $this->addMembers([$user]); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @param User[] $users |
| 136 | 136 | * @return $this |
| 137 | 137 | */ |
| 138 | - public function addMembers (array $users) { |
|
| 138 | + public function addMembers(array $users) { |
|
| 139 | 139 | return $this->_addWithPost("{$this}/addMembers", [ |
| 140 | 140 | 'members' => array_column($users, 'gid') |
| 141 | 141 | ], 'members', $users); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param array $schedule |
| 160 | 160 | * @return Job |
| 161 | 161 | */ |
| 162 | - public function duplicate (string $name, array $include, Team $team = null, array $schedule = []) { |
|
| 162 | + public function duplicate(string $name, array $include, Team $team = null, array $schedule = []) { |
|
| 163 | 163 | $data = ['name' => $name]; |
| 164 | 164 | if ($team) { |
| 165 | 165 | $data['team'] = $team->getGid(); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | /** |
| 179 | 179 | * @return Section |
| 180 | 180 | */ |
| 181 | - public function getDefaultSection () { |
|
| 181 | + public function getDefaultSection() { |
|
| 182 | 182 | return $this->defaultSection ?? $this->defaultSection = $this->getSections(1)[0]; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @param int $limit |
| 191 | 191 | * @return Traversable|Section[] |
| 192 | 192 | */ |
| 193 | - public function getIterator (int $limit = PHP_INT_MAX) { |
|
| 193 | + public function getIterator(int $limit = PHP_INT_MAX) { |
|
| 194 | 194 | return $this->api->loadEach($this, Section::class, "{$this}/sections", ['limit' => $limit]); |
| 195 | 195 | } |
| 196 | 196 | |
@@ -198,21 +198,21 @@ discard block |
||
| 198 | 198 | * @param int $limit |
| 199 | 199 | * @return Section[] |
| 200 | 200 | */ |
| 201 | - public function getSections (int $limit = PHP_INT_MAX) { |
|
| 201 | + public function getSections(int $limit = PHP_INT_MAX) { |
|
| 202 | 202 | return iterator_to_array($this->getIterator($limit)); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | * @return Status[] |
| 207 | 207 | */ |
| 208 | - public function getStatuses () { |
|
| 208 | + public function getStatuses() { |
|
| 209 | 209 | return $this->api->loadAll($this, Status::class, "{$this}/project_statuses"); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
| 213 | 213 | * @return TaskCounts |
| 214 | 214 | */ |
| 215 | - public function getTaskCounts () { |
|
| 215 | + public function getTaskCounts() { |
|
| 216 | 216 | $remote = $this->api->get("{$this}/task_counts", [ |
| 217 | 217 | 'opt_fields' => // opt_expand doesn't work. |
| 218 | 218 | 'num_completed_milestones,' |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param array $filter |
| 232 | 232 | * @return Task[] |
| 233 | 233 | */ |
| 234 | - public function getTasks (array $filter = Task::GET_INCOMPLETE) { |
|
| 234 | + public function getTasks(array $filter = Task::GET_INCOMPLETE) { |
|
| 235 | 235 | $filter['project'] = $this->getGid(); |
| 236 | 236 | return $this->api->loadAll($this, Task::class, "tasks", $filter); |
| 237 | 237 | } |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | /** |
| 240 | 240 | * @return string |
| 241 | 241 | */ |
| 242 | - final public function getUrl (): string { |
|
| 242 | + final public function getUrl(): string { |
|
| 243 | 243 | return "https://app.asana.com/0/{$this->getGid()}"; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
| 247 | 247 | * @return ProjectWebhook[] |
| 248 | 248 | */ |
| 249 | - public function getWebhooks () { |
|
| 249 | + public function getWebhooks() { |
|
| 250 | 250 | return $this->api->loadAll($this, ProjectWebhook::class, 'webhooks', [ |
| 251 | 251 | 'workspace' => $this->getWorkspace()->getGid(), |
| 252 | 252 | 'resource' => $this->getGid() |
@@ -256,21 +256,21 @@ discard block |
||
| 256 | 256 | /** |
| 257 | 257 | * @return bool |
| 258 | 258 | */ |
| 259 | - final public function isBoard (): bool { |
|
| 259 | + final public function isBoard(): bool { |
|
| 260 | 260 | return $this->getLayout() === self::LAYOUT_BOARD; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
| 264 | 264 | * @return bool |
| 265 | 265 | */ |
| 266 | - final public function isList (): bool { |
|
| 266 | + final public function isList(): bool { |
|
| 267 | 267 | return $this->getLayout() === self::LAYOUT_LIST; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * @return bool |
| 272 | 272 | */ |
| 273 | - final public function isTemplate (): bool { |
|
| 273 | + final public function isTemplate(): bool { |
|
| 274 | 274 | return $this->_is('is_template'); |
| 275 | 275 | } |
| 276 | 276 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @return Section |
| 281 | 281 | */ |
| 282 | - public function newSection () { |
|
| 282 | + public function newSection() { |
|
| 283 | 283 | return $this->api->factory($this, Section::class, ['project' => $this]); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * |
| 289 | 289 | * @return Status |
| 290 | 290 | */ |
| 291 | - public function newStatus () { |
|
| 291 | + public function newStatus() { |
|
| 292 | 292 | return $this->api->factory($this, Status::class); |
| 293 | 293 | } |
| 294 | 294 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * |
| 298 | 298 | * @return Task |
| 299 | 299 | */ |
| 300 | - public function newTask () { |
|
| 300 | + public function newTask() { |
|
| 301 | 301 | return $this->getDefaultSection()->newTask(); |
| 302 | 302 | } |
| 303 | 303 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * |
| 307 | 307 | * @return ProjectWebhook |
| 308 | 308 | */ |
| 309 | - public function newWebhook () { |
|
| 309 | + public function newWebhook() { |
|
| 310 | 310 | /** @var ProjectWebhook $webhook */ |
| 311 | 311 | $webhook = $this->api->factory($this, ProjectWebhook::class); |
| 312 | 312 | return $webhook->setResource($this); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @param User $user |
| 317 | 317 | * @return $this |
| 318 | 318 | */ |
| 319 | - public function removeFollower (User $user) { |
|
| 319 | + public function removeFollower(User $user) { |
|
| 320 | 320 | return $this->removeFollowers([$user]); |
| 321 | 321 | } |
| 322 | 322 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | * @param User[] $users |
| 325 | 325 | * @return $this |
| 326 | 326 | */ |
| 327 | - public function removeFollowers (array $users) { |
|
| 327 | + public function removeFollowers(array $users) { |
|
| 328 | 328 | return $this->_removeWithPost("{$this}/removeFollowers", [ |
| 329 | 329 | 'followers' => array_column($users, 'gid') |
| 330 | 330 | ], 'followers', $users); |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | * @param User $user |
| 335 | 335 | * @return $this |
| 336 | 336 | */ |
| 337 | - public function removeMember (User $user) { |
|
| 337 | + public function removeMember(User $user) { |
|
| 338 | 338 | return $this->removeMembers([$user]); |
| 339 | 339 | } |
| 340 | 340 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @param User[] $users |
| 343 | 343 | * @return $this |
| 344 | 344 | */ |
| 345 | - public function removeMembers (array $users) { |
|
| 345 | + public function removeMembers(array $users) { |
|
| 346 | 346 | return $this->_removeWithPost("{$this}/removeMembers", [ |
| 347 | 347 | 'members' => array_column($users, 'gid') |
| 348 | 348 | ], 'members', $users); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @param User $user |
| 67 | 67 | * @return $this |
| 68 | 68 | */ |
| 69 | - public function addMember (User $user) { |
|
| 69 | + public function addMember(User $user) { |
|
| 70 | 70 | return $this->addMembers([$user]); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param User[] $users |
| 75 | 75 | * @return $this |
| 76 | 76 | */ |
| 77 | - public function addMembers (array $users) { |
|
| 77 | + public function addMembers(array $users) { |
|
| 78 | 78 | return $this->_addWithPost("{$this}/addMembers", [ |
| 79 | 79 | 'members' => array_column($users, 'gid') |
| 80 | 80 | ], 'members', $users); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param Project $project |
| 85 | 85 | * @return $this |
| 86 | 86 | */ |
| 87 | - public function addProject (Project $project) { |
|
| 87 | + public function addProject(Project $project) { |
|
| 88 | 88 | $this->api->post("{$this}/addItem", ['item' => $project->getGid()]); |
| 89 | 89 | return $this; |
| 90 | 90 | } |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return Traversable|Project[] |
| 96 | 96 | */ |
| 97 | - public function getIterator () { |
|
| 97 | + public function getIterator() { |
|
| 98 | 98 | return $this->api->loadEach($this, Project::class, "{$this}/items"); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * @return Project[] |
| 103 | 103 | */ |
| 104 | - public function getProjects () { |
|
| 104 | + public function getProjects() { |
|
| 105 | 105 | return iterator_to_array($this); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @param User $user |
| 110 | 110 | * @return $this |
| 111 | 111 | */ |
| 112 | - public function removeMember (User $user) { |
|
| 112 | + public function removeMember(User $user) { |
|
| 113 | 113 | return $this->removeMembers([$user]); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @param User[] $users |
| 118 | 118 | * @return $this |
| 119 | 119 | */ |
| 120 | - public function removeMembers (array $users) { |
|
| 120 | + public function removeMembers(array $users) { |
|
| 121 | 121 | return $this->_removeWithPost("{$this}/removeMembers", [ |
| 122 | 122 | 'members' => array_column($users, 'gid') |
| 123 | 123 | ], 'members', $users); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param Project $project |
| 128 | 128 | * @return $this |
| 129 | 129 | */ |
| 130 | - public function removeProject (Project $project) { |
|
| 130 | + public function removeProject(Project $project) { |
|
| 131 | 131 | $this->api->post("{$this}/removeItem", ['item' => $project->getGid()]); |
| 132 | 132 | return $this; |
| 133 | 133 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @param callable $filter `fn( Project $project ): bool` |
| 137 | 137 | * @return Project[] |
| 138 | 138 | */ |
| 139 | - public function selectProjects (callable $filter) { |
|
| 139 | + public function selectProjects(callable $filter) { |
|
| 140 | 140 | return $this->_select($this, $filter); |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param User $user |
| 31 | 31 | * @return $this |
| 32 | 32 | */ |
| 33 | - public function addUser (User $user) { |
|
| 33 | + public function addUser(User $user) { |
|
| 34 | 34 | $this->api->post("{$this}/addUser", ['user' => $user->getGid()]); |
| 35 | 35 | return $this; |
| 36 | 36 | } |
@@ -43,14 +43,14 @@ discard block |
||
| 43 | 43 | * @param array $filter |
| 44 | 44 | * @return Project[] |
| 45 | 45 | */ |
| 46 | - public function getProjects (array $filter = Project::GET_ACTIVE) { |
|
| 46 | + public function getProjects(array $filter = Project::GET_ACTIVE) { |
|
| 47 | 47 | return $this->api->loadAll($this, Project::class, "{$this}/projects", $filter); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * @return string |
| 52 | 52 | */ |
| 53 | - final public function getUrl (): string { |
|
| 53 | + final public function getUrl(): string { |
|
| 54 | 54 | return "https://app.asana.com/0/{$this->getGid()}/overview"; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return User[] |
| 63 | 63 | */ |
| 64 | - public function getUsers () { |
|
| 64 | + public function getUsers() { |
|
| 65 | 65 | return $this->api->loadAll($this, User::class, "{$this}/users"); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @return Project |
| 72 | 72 | */ |
| 73 | - public function newProject () { |
|
| 73 | + public function newProject() { |
|
| 74 | 74 | /** @var Project $project */ |
| 75 | 75 | $project = $this->api->factory($this, Project::class, [ |
| 76 | 76 | 'workspace' => $this->getOrganization() |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param User $user |
| 83 | 83 | * @return $this |
| 84 | 84 | */ |
| 85 | - public function removeUser (User $user) { |
|
| 85 | + public function removeUser(User $user) { |
|
| 86 | 86 | $this->api->post("{$this}/removeUser", ['user' => $user->getGid()]); |
| 87 | 87 | return $this; |
| 88 | 88 | } |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | 'target' => Task::class |
| 52 | 52 | ]; |
| 53 | 53 | |
| 54 | - public function __construct ($caller, array $data = []) { |
|
| 54 | + public function __construct($caller, array $data = []) { |
|
| 55 | 55 | parent::__construct($caller, $data); |
| 56 | 56 | $this->parent = $this->getTarget(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - protected function _setData (array $data): void { |
|
| 59 | + protected function _setData(array $data): void { |
|
| 60 | 60 | // hearts were deprecated for likes |
| 61 | 61 | unset($data['hearted'], $data['hearts'], $data['num_hearts']); |
| 62 | 62 | |
@@ -66,70 +66,70 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * @return bool |
| 68 | 68 | */ |
| 69 | - final public function isAssignment (): bool { |
|
| 69 | + final public function isAssignment(): bool { |
|
| 70 | 70 | return $this->getResourceSubtype() === self::TYPE_ASSIGNED; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @return bool |
| 75 | 75 | */ |
| 76 | - final public function isComment (): bool { |
|
| 76 | + final public function isComment(): bool { |
|
| 77 | 77 | return $this->getResourceSubtype() === self::TYPE_COMMENT_ADDED; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * @return bool |
| 82 | 82 | */ |
| 83 | - final public function isDueDate (): bool { |
|
| 83 | + final public function isDueDate(): bool { |
|
| 84 | 84 | return $this->getResourceSubtype() === self::TYPE_DUE_DATE_CHANGED; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * @return bool |
| 89 | 89 | */ |
| 90 | - final public function isEdited (): bool { |
|
| 90 | + final public function isEdited(): bool { |
|
| 91 | 91 | return $this->_is('is_edited'); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | 95 | * @return bool |
| 96 | 96 | */ |
| 97 | - final public function isFromApi (): bool { |
|
| 97 | + final public function isFromApi(): bool { |
|
| 98 | 98 | return $this->getSource() === 'api'; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * @return bool |
| 103 | 103 | */ |
| 104 | - final public function isFromWeb (): bool { |
|
| 104 | + final public function isFromWeb(): bool { |
|
| 105 | 105 | return $this->getSource() === 'web'; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * @return bool |
| 110 | 110 | */ |
| 111 | - final public function isLikedComment (): bool { |
|
| 111 | + final public function isLikedComment(): bool { |
|
| 112 | 112 | return $this->getResourceSubtype() === self::TYPE_COMMENT_LIKED; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @return bool |
| 117 | 117 | */ |
| 118 | - final public function isLikedTask (): bool { |
|
| 118 | + final public function isLikedTask(): bool { |
|
| 119 | 119 | return $this->getResourceSubtype() === self::TYPE_LIKED; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | 123 | * @return bool |
| 124 | 124 | */ |
| 125 | - final public function isPinned (): bool { |
|
| 125 | + final public function isPinned(): bool { |
|
| 126 | 126 | return $this->_is('is_pinned'); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | * @return bool |
| 131 | 131 | */ |
| 132 | - final public function isTag (): bool { |
|
| 132 | + final public function isTag(): bool { |
|
| 133 | 133 | return $this->getResourceSubtype() === self::TYPE_TAGGED; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param bool $pinned |
| 138 | 138 | * @return $this |
| 139 | 139 | */ |
| 140 | - final public function setPinned (bool $pinned) { |
|
| 140 | + final public function setPinned(bool $pinned) { |
|
| 141 | 141 | return $this->_set('is_pinned', $pinned); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * @param Section $section |
| 31 | 31 | * @return $this |
| 32 | 32 | */ |
| 33 | - final public function setSection (Section $section) { |
|
| 33 | + final public function setSection(Section $section) { |
|
| 34 | 34 | $this->_set('project', $section->getProject()); |
| 35 | 35 | $this->_set('section', $section); |
| 36 | 36 | return $this; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param Change|FieldEntries $caller |
| 32 | 32 | * @param array $data |
| 33 | 33 | */ |
| 34 | - public function __construct ($caller, array $data = []) { |
|
| 34 | + public function __construct($caller, array $data = []) { |
|
| 35 | 35 | $this->caller = $caller; |
| 36 | 36 | parent::__construct($caller, $data); |
| 37 | 37 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | - public function __toString (): string { |
|
| 42 | + public function __toString(): string { |
|
| 43 | 43 | if ($this->isEnum()) { |
| 44 | 44 | return (string)$this->getCurrentOptionName(); |
| 45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @param array $data |
| 53 | 53 | */ |
| 54 | - protected function _setData (array $data): void { |
|
| 54 | + protected function _setData(array $data): void { |
|
| 55 | 55 | if (isset($data['resource_subtype'])) { // sentinel for bloat |
| 56 | 56 | $tiny = array_intersect_key($data, array_flip([ |
| 57 | 57 | 'gid', |
@@ -77,21 +77,21 @@ discard block |
||
| 77 | 77 | * @param null|string $value |
| 78 | 78 | * @return null|string |
| 79 | 79 | */ |
| 80 | - protected function _toEnumOptionGid ($value) { |
|
| 80 | + protected function _toEnumOptionGid($value) { |
|
| 81 | 81 | return $this->getEnumOptionValues()[$value] ?? $value; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * @return string |
| 86 | 86 | */ |
| 87 | - final public function getCurrentOptionName (): string { |
|
| 87 | + final public function getCurrentOptionName(): string { |
|
| 88 | 88 | return $this->getEnumOptionNames()[$this->getValue()]; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * @return CustomField |
| 93 | 93 | */ |
| 94 | - public function getCustomField () { |
|
| 94 | + public function getCustomField() { |
|
| 95 | 95 | return $this->api->getCustomField($this->getGid()); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @return string[] |
| 102 | 102 | */ |
| 103 | - final public function getEnumOptionNames () { |
|
| 103 | + final public function getEnumOptionNames() { |
|
| 104 | 104 | static $names = []; // shared |
| 105 | 105 | $gid = $this->data['gid']; |
| 106 | 106 | return $names[$gid] ?? $names[$gid] = array_column($this->data['enum_options'], 'name', 'gid'); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @return string[] |
| 113 | 113 | */ |
| 114 | - final public function getEnumOptionValues () { |
|
| 114 | + final public function getEnumOptionValues() { |
|
| 115 | 115 | static $values = []; // shared |
| 116 | 116 | $gid = $this->data['gid']; |
| 117 | 117 | return $values[$gid] ?? $values[$gid] = array_column($this->data['enum_options'], 'gid', 'name'); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | /** |
| 121 | 121 | * @return null|number|string |
| 122 | 122 | */ |
| 123 | - final public function getValue () { |
|
| 123 | + final public function getValue() { |
|
| 124 | 124 | $type = $this->data['type']; |
| 125 | 125 | if ($type === CustomField::TYPE_ENUM) { |
| 126 | 126 | return $this->data['enum_value']['gid'] ?? null; |
@@ -131,21 +131,21 @@ discard block |
||
| 131 | 131 | /** |
| 132 | 132 | * @return bool |
| 133 | 133 | */ |
| 134 | - final public function isEnum (): bool { |
|
| 134 | + final public function isEnum(): bool { |
|
| 135 | 135 | return $this->getType() === CustomField::TYPE_ENUM; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * @return bool |
| 140 | 140 | */ |
| 141 | - final public function isNumber (): bool { |
|
| 141 | + final public function isNumber(): bool { |
|
| 142 | 142 | return $this->getType() === CustomField::TYPE_NUMBER; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | 146 | * @return bool |
| 147 | 147 | */ |
| 148 | - final public function isText (): bool { |
|
| 148 | + final public function isText(): bool { |
|
| 149 | 149 | return $this->getType() === CustomField::TYPE_TEXT; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param null|number|string $value |
| 154 | 154 | * @return $this |
| 155 | 155 | */ |
| 156 | - final public function setValue ($value) { |
|
| 156 | + final public function setValue($value) { |
|
| 157 | 157 | if ($this->caller instanceof FieldEntries) { // read-only if the entry is in an event change. |
| 158 | 158 | $type = $this->data['type']; |
| 159 | 159 | $this->diff["{$type}_value"] = true; |