@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @return $this |
| 18 | 18 | */ |
| 19 | - public function update () { |
|
| 19 | + public function update() { |
|
| 20 | 20 | if ($this->isDiff()) { |
| 21 | 21 | /** @var array $remote */ |
| 22 | 22 | $remote = $this->api->put($this, $this->getDiff(), ['expand' => 'this']); |
@@ -16,14 +16,14 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @return string |
| 18 | 18 | */ |
| 19 | - abstract protected function _getDir (): string; |
|
| 19 | + abstract protected function _getDir(): string; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * `POST` the new entity to Asana. |
| 23 | 23 | * |
| 24 | 24 | * @return $this |
| 25 | 25 | */ |
| 26 | - public function create () { |
|
| 26 | + public function create() { |
|
| 27 | 27 | /** @var array $remote */ |
| 28 | 28 | $remote = $this->api->post($this->_getDir(), $this->getDiff(), ['expand' => 'this']); |
| 29 | 29 | $this->_setData($remote); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @return CustomField[] |
| 19 | 19 | */ |
| 20 | - public function getCustomFields () { |
|
| 20 | + public function getCustomFields() { |
|
| 21 | 21 | return array_column($this->getCustomFieldSettings(), 'custom_field'); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param callable $filter `fn( CustomField $field ): bool` |
| 26 | 26 | * @return CustomField[] |
| 27 | 27 | */ |
| 28 | - public function selectCustomFields (callable $filter) { |
|
| 28 | + public function selectCustomFields(callable $filter) { |
|
| 29 | 29 | return $this->_select($this->getCustomFields(), $filter); |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | 'memberships' => 'memberships.(project|section)' |
| 102 | 102 | ]; |
| 103 | 103 | |
| 104 | - final public function __toString (): string { |
|
| 104 | + final public function __toString(): string { |
|
| 105 | 105 | return "tasks/{$this->getGid()}"; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - final protected function _getDir (): string { |
|
| 108 | + final protected function _getDir(): string { |
|
| 109 | 109 | return 'tasks'; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - protected function _onSave (): void { |
|
| 112 | + protected function _onSave(): void { |
|
| 113 | 113 | // use isset() to avoid has() fetch. |
| 114 | 114 | if (isset($this->data['custom_fields'])) { |
| 115 | 115 | $this->getCustomFields()->diff = []; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - protected function _setData (array $data): void { |
|
| 122 | + protected function _setData(array $data): void { |
|
| 123 | 123 | // hearts were deprecated for likes |
| 124 | 124 | unset($data['hearted'], $data['hearts'], $data['num_hearts']); |
| 125 | 125 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param string $file |
| 140 | 140 | * @return Attachment |
| 141 | 141 | */ |
| 142 | - public function addAttachment (string $file) { |
|
| 142 | + public function addAttachment(string $file) { |
|
| 143 | 143 | /** @var Attachment $attachment */ |
| 144 | 144 | $attachment = $this->api->factory($this, Attachment::class, ['parent' => $this]); |
| 145 | 145 | return $attachment->upload($file); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @param string $text |
| 152 | 152 | * @return Story |
| 153 | 153 | */ |
| 154 | - public function addComment (string $text) { |
|
| 154 | + public function addComment(string $text) { |
|
| 155 | 155 | return $this->newComment()->setText($text)->create(); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param Task[] $tasks |
| 163 | 163 | * @return $this |
| 164 | 164 | */ |
| 165 | - public function addDependencies (array $tasks) { |
|
| 165 | + public function addDependencies(array $tasks) { |
|
| 166 | 166 | $this->api->post("{$this}/addDependencies", ['dependents' => array_column($tasks, 'gid')]); |
| 167 | 167 | return $this; |
| 168 | 168 | } |
@@ -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 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * @param Task $task |
| 186 | 186 | * @return $this |
| 187 | 187 | */ |
| 188 | - public function addDependent (Task $task) { |
|
| 188 | + public function addDependent(Task $task) { |
|
| 189 | 189 | return $this->addDependents([$task]); |
| 190 | 190 | } |
| 191 | 191 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @param Task[] $tasks |
| 197 | 197 | * @return $this |
| 198 | 198 | */ |
| 199 | - public function addDependents (array $tasks) { |
|
| 199 | + public function addDependents(array $tasks) { |
|
| 200 | 200 | $this->api->post("{$this}/addDependents", ['dependents' => array_column($tasks, 'gid')]); |
| 201 | 201 | return $this; |
| 202 | 202 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * @param User $user |
| 208 | 208 | * @return $this |
| 209 | 209 | */ |
| 210 | - public function addFollower (User $user) { |
|
| 210 | + public function addFollower(User $user) { |
|
| 211 | 211 | return $this->addFollowers([$user]); |
| 212 | 212 | } |
| 213 | 213 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * @param User[] $users |
| 220 | 220 | * @return $this |
| 221 | 221 | */ |
| 222 | - public function addFollowers (array $users) { |
|
| 222 | + public function addFollowers(array $users) { |
|
| 223 | 223 | return $this->_addWithPost("{$this}/addFollowers", [ |
| 224 | 224 | 'followers' => array_column($users, 'gid') |
| 225 | 225 | ], 'followers', $users); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @param Tag $tag |
| 234 | 234 | * @return $this |
| 235 | 235 | */ |
| 236 | - public function addTag (Tag $tag) { |
|
| 236 | + public function addTag(Tag $tag) { |
|
| 237 | 237 | return $this->_addWithPost("{$this}/addTag", [ |
| 238 | 238 | 'tag' => $tag->getGid() |
| 239 | 239 | ], 'tags', [$tag]); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @param Section $section |
| 250 | 250 | * @return $this |
| 251 | 251 | */ |
| 252 | - public function addToProject (Section $section) { |
|
| 252 | + public function addToProject(Section $section) { |
|
| 253 | 253 | /** @var Membership $membership */ |
| 254 | 254 | $membership = $this->api->factory($this, Membership::class) |
| 255 | 255 | ->_set('project', $section->getProject()) |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * @param string $target |
| 265 | 265 | * @return TaskWebhook |
| 266 | 266 | */ |
| 267 | - public function addWebhook (string $target) { |
|
| 267 | + public function addWebhook(string $target) { |
|
| 268 | 268 | /** @var TaskWebhook $webhook */ |
| 269 | 269 | $webhook = $this->api->factory($this, TaskWebhook::class); |
| 270 | 270 | return $webhook->create($this, $target); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | /** |
| 274 | 274 | * @return $this |
| 275 | 275 | */ |
| 276 | - public function create () { |
|
| 276 | + public function create() { |
|
| 277 | 277 | $this->_create(); |
| 278 | 278 | $this->_onSave(); |
| 279 | 279 | return $this; |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @param string[] $include |
| 290 | 290 | * @return Job |
| 291 | 291 | */ |
| 292 | - public function duplicate (string $name, array $include) { |
|
| 292 | + public function duplicate(string $name, array $include) { |
|
| 293 | 293 | /** @var array $remote */ |
| 294 | 294 | $remote = $this->api->post("{$this}/duplicate", [ |
| 295 | 295 | 'name' => $name, |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * @depends after-create |
| 305 | 305 | * @return Attachment[] |
| 306 | 306 | */ |
| 307 | - public function getAttachments () { |
|
| 307 | + public function getAttachments() { |
|
| 308 | 308 | return $this->api->loadAll($this, Attachment::class, "{$this}/attachments"); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * @depends after-create |
| 315 | 315 | * @return Story[] |
| 316 | 316 | */ |
| 317 | - public function getComments () { |
|
| 317 | + public function getComments() { |
|
| 318 | 318 | return $this->selectStories(function(Story $story) { |
| 319 | 319 | return $story->isComment(); |
| 320 | 320 | }); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @depends after-create |
| 327 | 327 | * @return Task[] |
| 328 | 328 | */ |
| 329 | - public function getDependencies () { |
|
| 329 | + public function getDependencies() { |
|
| 330 | 330 | return $this->api->loadAll($this, self::class, "{$this}/dependencies"); |
| 331 | 331 | } |
| 332 | 332 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * @depends after-create |
| 337 | 337 | * @return Task[] |
| 338 | 338 | */ |
| 339 | - public function getDependents () { |
|
| 339 | + public function getDependents() { |
|
| 340 | 340 | return $this->api->loadAll($this, self::class, "{$this}/dependents"); |
| 341 | 341 | } |
| 342 | 342 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @param null|string $token |
| 348 | 348 | * @return Event[] |
| 349 | 349 | */ |
| 350 | - public function getEvents (&$token) { |
|
| 350 | + public function getEvents(&$token) { |
|
| 351 | 351 | return $this->api->sync($this->getGid(), $token); |
| 352 | 352 | } |
| 353 | 353 | |
@@ -359,21 +359,21 @@ discard block |
||
| 359 | 359 | * |
| 360 | 360 | * @return External |
| 361 | 361 | */ |
| 362 | - public function getExternal () { |
|
| 362 | + public function getExternal() { |
|
| 363 | 363 | return $this->_get('external') ?? $this->data['external'] = $this->api->factory($this, External::class); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | /** |
| 367 | 367 | * @return Project[] |
| 368 | 368 | */ |
| 369 | - public function getProjects () { |
|
| 369 | + public function getProjects() { |
|
| 370 | 370 | return array_column($this->getMemberships(), 'project'); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * @return Section[] |
| 375 | 375 | */ |
| 376 | - public function getSections () { |
|
| 376 | + public function getSections() { |
|
| 377 | 377 | return array_column($this->getMemberships(), 'section'); |
| 378 | 378 | } |
| 379 | 379 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @depends after-create |
| 384 | 384 | * @return Story[] |
| 385 | 385 | */ |
| 386 | - public function getStories () { |
|
| 386 | + public function getStories() { |
|
| 387 | 387 | return $this->api->loadAll($this, Story::class, "{$this}/stories"); |
| 388 | 388 | } |
| 389 | 389 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | * @depends after-create |
| 394 | 394 | * @return Task[] |
| 395 | 395 | */ |
| 396 | - public function getSubTasks () { |
|
| 396 | + public function getSubTasks() { |
|
| 397 | 397 | return $this->api->loadAll($this, self::class, "{$this}/subtasks"); |
| 398 | 398 | } |
| 399 | 399 | |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | * @depends after-create |
| 404 | 404 | * @return string |
| 405 | 405 | */ |
| 406 | - public function getUrl (): string { |
|
| 406 | + public function getUrl(): string { |
|
| 407 | 407 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
| 408 | 408 | } |
| 409 | 409 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | * @depends after-create |
| 414 | 414 | * @return TaskWebhook[] |
| 415 | 415 | */ |
| 416 | - public function getWebhooks () { |
|
| 416 | + public function getWebhooks() { |
|
| 417 | 417 | return $this->api->loadAll($this, TaskWebhook::class, 'webhooks', [ |
| 418 | 418 | 'workspace' => $this->getWorkspace()->getGid(), |
| 419 | 419 | 'resource' => $this->getGid() |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | /** |
| 424 | 424 | * @return bool |
| 425 | 425 | */ |
| 426 | - public function isRenderedAsSeparator (): bool { |
|
| 426 | + public function isRenderedAsSeparator(): bool { |
|
| 427 | 427 | return $this->_is('is_rendered_as_separator'); |
| 428 | 428 | } |
| 429 | 429 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | * @depends after-create |
| 434 | 434 | * @return Story |
| 435 | 435 | */ |
| 436 | - public function newComment () { |
|
| 436 | + public function newComment() { |
|
| 437 | 437 | return $this->api->factory($this, Story::class, [ |
| 438 | 438 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED, |
| 439 | 439 | 'target' => $this |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | * @depends after-create |
| 447 | 447 | * @return Task |
| 448 | 448 | */ |
| 449 | - public function newSubTask () { |
|
| 449 | + public function newSubTask() { |
|
| 450 | 450 | /** @var Task $sub */ |
| 451 | 451 | $sub = $this->api->factory($this, self::class); |
| 452 | 452 | return $sub->setParent($this); |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | * @param Task[] $tasks |
| 460 | 460 | * @return $this |
| 461 | 461 | */ |
| 462 | - public function removeDependencies (array $tasks) { |
|
| 462 | + public function removeDependencies(array $tasks) { |
|
| 463 | 463 | $this->api->post("{$this}/removeDependencies", ['dependencies' => array_column($tasks, 'gid')]); |
| 464 | 464 | return $this; |
| 465 | 465 | } |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | * @param Task $task |
| 472 | 472 | * @return $this |
| 473 | 473 | */ |
| 474 | - public function removeDependency (Task $task) { |
|
| 474 | + public function removeDependency(Task $task) { |
|
| 475 | 475 | return $this->removeDependencies([$task]); |
| 476 | 476 | } |
| 477 | 477 | |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | * @param Task $task |
| 483 | 483 | * @return $this |
| 484 | 484 | */ |
| 485 | - public function removeDependent (Task $task) { |
|
| 485 | + public function removeDependent(Task $task) { |
|
| 486 | 486 | return $this->removeDependents([$task]); |
| 487 | 487 | } |
| 488 | 488 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * @param Task[] $tasks |
| 494 | 494 | * @return $this |
| 495 | 495 | */ |
| 496 | - public function removeDependents (array $tasks) { |
|
| 496 | + public function removeDependents(array $tasks) { |
|
| 497 | 497 | $this->api->post("{$this}/removeDependents", ['dependents' => array_column($tasks, 'gid')]); |
| 498 | 498 | return $this; |
| 499 | 499 | } |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | * @param User $user |
| 505 | 505 | * @return $this |
| 506 | 506 | */ |
| 507 | - public function removeFollower (User $user) { |
|
| 507 | + public function removeFollower(User $user) { |
|
| 508 | 508 | return $this->removeFollowers([$user]); |
| 509 | 509 | } |
| 510 | 510 | |
@@ -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 | return $this->_removeWithPost("{$this}/removeFollowers", [ |
| 521 | 521 | 'followers' => array_column($users, 'gid') |
| 522 | 522 | ], 'followers', $users); |
@@ -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 | return $this->_removeWithPost("{$this}/removeProject", [ |
| 535 | 535 | 'project' => $project->getGid() |
| 536 | 536 | ], 'memberships', function(Membership $membership) use ($project) { |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | * @param Tag $tag |
| 547 | 547 | * @return $this |
| 548 | 548 | */ |
| 549 | - public function removeTag (Tag $tag) { |
|
| 549 | + public function removeTag(Tag $tag) { |
|
| 550 | 550 | return $this->_removeWithPost("{$this}/removeTag", [ |
| 551 | 551 | 'tag' => $tag->getGid() |
| 552 | 552 | ], 'tags', [$tag]); |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | * @param callable $filter `fn( Attachment $attachment): bool` |
| 557 | 557 | * @return Attachment[] |
| 558 | 558 | */ |
| 559 | - public function selectAttachments (callable $filter) { |
|
| 559 | + public function selectAttachments(callable $filter) { |
|
| 560 | 560 | return $this->_select($this->getAttachments(), $filter); |
| 561 | 561 | } |
| 562 | 562 | |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | * @param callable $filter `fn( Story $comment ): bool` |
| 565 | 565 | * @return Story[] |
| 566 | 566 | */ |
| 567 | - public function selectComments (callable $filter) { |
|
| 567 | + public function selectComments(callable $filter) { |
|
| 568 | 568 | return $this->_select($this->getComments(), $filter); |
| 569 | 569 | } |
| 570 | 570 | |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | * @param callable $filter `fn( Task $dependency ): bool` |
| 573 | 573 | * @return Task[] |
| 574 | 574 | */ |
| 575 | - public function selectDependencies (callable $filter) { |
|
| 575 | + public function selectDependencies(callable $filter) { |
|
| 576 | 576 | return $this->_select($this->getDependencies(), $filter); |
| 577 | 577 | } |
| 578 | 578 | |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | * @param callable $filter `fn( Task $dependent ): bool` |
| 581 | 581 | * @return Task[] |
| 582 | 582 | */ |
| 583 | - public function selectDependents (callable $filter) { |
|
| 583 | + public function selectDependents(callable $filter) { |
|
| 584 | 584 | return $this->_select($this->getDependents(), $filter); |
| 585 | 585 | } |
| 586 | 586 | |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | * @param callable $filter `fn( Project $project ): bool` |
| 589 | 589 | * @return Project[] |
| 590 | 590 | */ |
| 591 | - public function selectProjects (callable $filter) { |
|
| 591 | + public function selectProjects(callable $filter) { |
|
| 592 | 592 | return $this->_select($this->getProjects(), $filter); |
| 593 | 593 | } |
| 594 | 594 | |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | * @param callable $filter `fn( Story $story ): bool` |
| 597 | 597 | * @return Story[] |
| 598 | 598 | */ |
| 599 | - public function selectStories (callable $filter) { |
|
| 599 | + public function selectStories(callable $filter) { |
|
| 600 | 600 | return $this->_select($this->getStories(), $filter); |
| 601 | 601 | } |
| 602 | 602 | |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @param callable $filter `fn( Task $subtask ): bool` |
| 605 | 605 | * @return Task[] |
| 606 | 606 | */ |
| 607 | - public function selectSubTasks (callable $filter) { |
|
| 607 | + public function selectSubTasks(callable $filter) { |
|
| 608 | 608 | return $this->_select($this->getSubTasks(), $filter); |
| 609 | 609 | } |
| 610 | 610 | |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | * @param null|string|DateTimeInterface $date |
| 613 | 613 | * @return Task |
| 614 | 614 | */ |
| 615 | - public function setDueOn ($date) { |
|
| 615 | + public function setDueOn($date) { |
|
| 616 | 616 | if ($date instanceof DateTimeInterface) { |
| 617 | 617 | $date = $date->format('Y-m-d'); |
| 618 | 618 | } |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | * @param null|Task $parent |
| 627 | 627 | * @return $this |
| 628 | 628 | */ |
| 629 | - public function setParent (?self $parent) { |
|
| 629 | + public function setParent(?self $parent) { |
|
| 630 | 630 | return $this->_setWithPost("{$this}/setParent", [ |
| 631 | 631 | 'parent' => $parent |
| 632 | 632 | ], 'parent', $parent); |
@@ -636,14 +636,14 @@ discard block |
||
| 636 | 636 | * @param bool $flag |
| 637 | 637 | * @return $this |
| 638 | 638 | */ |
| 639 | - public function setRenderedAsSeparator (bool $flag) { |
|
| 639 | + public function setRenderedAsSeparator(bool $flag) { |
|
| 640 | 640 | return $this->_set('is_rendered_as_separator', $flag); |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
| 644 | 644 | * @return $this |
| 645 | 645 | */ |
| 646 | - public function update () { |
|
| 646 | + public function update() { |
|
| 647 | 647 | $this->_update(); |
| 648 | 648 | $this->_onSave(); |
| 649 | 649 | return $this; |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | * @param Workspace $workspace |
| 18 | 18 | * @return $this |
| 19 | 19 | */ |
| 20 | - public function setWorkspace (Workspace $workspace) { |
|
| 20 | + public function setWorkspace(Workspace $workspace) { |
|
| 21 | 21 | return $this->_set('workspace', $workspace); |
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -26,14 +26,14 @@ discard block |
||
| 26 | 26 | * @param null|string $value |
| 27 | 27 | * @return null|string |
| 28 | 28 | */ |
| 29 | - protected function _toEnumOptionGid ($value) { |
|
| 29 | + protected function _toEnumOptionGid($value) { |
|
| 30 | 30 | return $this->getEnumOptionValues()[$value] ?? $value; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * @return string |
| 35 | 35 | */ |
| 36 | - public function getCurrentOptionName () { |
|
| 36 | + public function getCurrentOptionName() { |
|
| 37 | 37 | return $this->getEnumOptionNames()[$this->getValue()]; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return string[] |
| 44 | 44 | */ |
| 45 | - public function getEnumOptionNames () { |
|
| 45 | + public function getEnumOptionNames() { |
|
| 46 | 46 | static $names = []; // shared |
| 47 | 47 | $gid = $this->data['gid']; |
| 48 | 48 | return $names[$gid] ?? $names[$gid] = array_column($this->data['enum_options'], 'name', 'gid'); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return string[] |
| 55 | 55 | */ |
| 56 | - public function getEnumOptionValues () { |
|
| 56 | + public function getEnumOptionValues() { |
|
| 57 | 57 | static $values = []; // shared |
| 58 | 58 | $gid = $this->data['gid']; |
| 59 | 59 | return $values[$gid] ?? $values[$gid] = array_column($this->data['enum_options'], 'gid', 'name'); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | /** |
| 63 | 63 | * @return null|number|string |
| 64 | 64 | */ |
| 65 | - public function getValue () { |
|
| 65 | + public function getValue() { |
|
| 66 | 66 | $type = $this->data['type']; |
| 67 | 67 | if ($type === CustomField::TYPE_ENUM) { |
| 68 | 68 | return $this->data['enum_value']['gid'] ?? null; |
@@ -70,15 +70,15 @@ discard block |
||
| 70 | 70 | return $this->data["{$type}_value"]; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - final public function isEnum (): bool { |
|
| 73 | + final public function isEnum(): bool { |
|
| 74 | 74 | return $this->getType() === CustomField::TYPE_ENUM; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - final public function isNumber (): bool { |
|
| 77 | + final public function isNumber(): bool { |
|
| 78 | 78 | return $this->getType() === CustomField::TYPE_NUMBER; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - final public function isText (): bool { |
|
| 81 | + final public function isText(): bool { |
|
| 82 | 82 | return $this->getType() === CustomField::TYPE_TEXT; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param null|number|string $value |
| 87 | 87 | * @return $this |
| 88 | 88 | */ |
| 89 | - public function setValue ($value) { |
|
| 89 | + public function setValue($value) { |
|
| 90 | 90 | $type = $this->data['type']; |
| 91 | 91 | $this->diff["{$type}_value"] = true; |
| 92 | 92 | if ($type === CustomField::TYPE_ENUM) { |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @return array |
| 104 | 104 | */ |
| 105 | - public function toArray (): array { |
|
| 105 | + public function toArray(): array { |
|
| 106 | 106 | // only strip if needed. |
| 107 | 107 | if (!isset($this->data['resource_subtype'])) { |
| 108 | 108 | return $this->data; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @param PSR16 $psr |
| 35 | 35 | */ |
| 36 | - public function __construct (PSR16 $psr) { |
|
| 36 | + public function __construct(PSR16 $psr) { |
|
| 37 | 37 | $this->psr = $psr; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param AbstractEntity $entity |
| 42 | 42 | * @throws CacheException |
| 43 | 43 | */ |
| 44 | - protected function _add (AbstractEntity $entity): void { |
|
| 44 | + protected function _add(AbstractEntity $entity): void { |
|
| 45 | 45 | $this->psr->set("asana/{$entity->getGid()}", $entity, $this->_getTtl($entity)); |
| 46 | 46 | parent::_add($entity); |
| 47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param string[] $keys |
| 52 | 52 | * @throws CacheException |
| 53 | 53 | */ |
| 54 | - protected function _addKeys (AbstractEntity $entity, ...$keys): void { |
|
| 54 | + protected function _addKeys(AbstractEntity $entity, ...$keys): void { |
|
| 55 | 55 | $gid = $entity->getGid(); |
| 56 | 56 | $ttl = $this->_getTtl($entity); |
| 57 | 57 | foreach ($keys as $key) { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return null|AbstractEntity |
| 69 | 69 | * @throws CacheException |
| 70 | 70 | */ |
| 71 | - protected function _get (string $key, $caller) { |
|
| 71 | + protected function _get(string $key, $caller) { |
|
| 72 | 72 | if (!$entity = parent::_get($key, $caller) and $entity = $this->psr->get("asana/{$key}")) { |
| 73 | 73 | if (is_string($entity)) { // gid ref |
| 74 | 74 | if (!$entity = $this->_get($entity, $caller)) { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | return $entity; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - protected function _getTtl (AbstractEntity $entity): int { |
|
| 86 | + protected function _getTtl(AbstractEntity $entity): int { |
|
| 87 | 87 | if ($entity instanceof ImmutableInterface) { |
| 88 | 88 | return strtotime('tomorrow') - time(); |
| 89 | 89 | } |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | * @return bool |
| 96 | 96 | * @throws CacheException |
| 97 | 97 | */ |
| 98 | - protected function _has (string $key): bool { |
|
| 98 | + protected function _has(string $key): bool { |
|
| 99 | 99 | return parent::_has($key) or $this->psr->has("asana/{$key}"); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * @return int |
| 104 | 104 | */ |
| 105 | - public function getTtl (): int { |
|
| 105 | + public function getTtl(): int { |
|
| 106 | 106 | return $this->ttl; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param string[] $keys |
| 111 | 111 | * @throws CacheException |
| 112 | 112 | */ |
| 113 | - public function remove (array $keys): void { |
|
| 113 | + public function remove(array $keys): void { |
|
| 114 | 114 | parent::remove($keys); |
| 115 | 115 | foreach ($keys as $key) { |
| 116 | 116 | $this->psr->delete("asana/{$key}"); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param int $ttl |
| 122 | 122 | * @return $this |
| 123 | 123 | */ |
| 124 | - public function setTtl (int $ttl) { |
|
| 124 | + public function setTtl(int $ttl) { |
|
| 125 | 125 | $this->ttl = $ttl; |
| 126 | 126 | return $this; |
| 127 | 127 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | 'workspace' => Workspace::class |
| 32 | 32 | ]; |
| 33 | 33 | |
| 34 | - final public function __toString (): string { |
|
| 34 | + final public function __toString(): string { |
|
| 35 | 35 | return "user_task_lists/{$this->getGid()}"; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | * @param array $filter |
| 40 | 40 | * @return Traversable|Task[] |
| 41 | 41 | */ |
| 42 | - public function getIterator (array $filter = Task::FILTER_INCOMPLETE) { |
|
| 42 | + public function getIterator(array $filter = Task::FILTER_INCOMPLETE) { |
|
| 43 | 43 | return $this->api->loadEach($this, Task::class, "{$this}/tasks", $filter); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function getPoolKeys () { |
|
| 46 | + public function getPoolKeys() { |
|
| 47 | 47 | $keys = parent::getPoolKeys(); |
| 48 | 48 | |
| 49 | 49 | /** @see User::getTaskList() */ |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param array $filter |
| 61 | 61 | * @return Task[] |
| 62 | 62 | */ |
| 63 | - public function getTasks (array $filter = Task::FILTER_INCOMPLETE) { |
|
| 63 | + public function getTasks(array $filter = Task::FILTER_INCOMPLETE) { |
|
| 64 | 64 | return iterator_to_array($this->getIterator($filter)); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param array $apiFilter Given to the API to reduce network load. |
| 70 | 70 | * @return Task[] |
| 71 | 71 | */ |
| 72 | - public function selectTasks (callable $filter, array $apiFilter) { |
|
| 72 | + public function selectTasks(callable $filter, array $apiFilter) { |
|
| 73 | 73 | return $this->_select($this->getIterator($apiFilter), $filter); |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | \ No newline at end of file |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | 'workspace' => Workspace::class |
| 35 | 35 | ]; |
| 36 | 36 | |
| 37 | - final public function __toString (): string { |
|
| 37 | + final public function __toString(): string { |
|
| 38 | 38 | return "tags/{$this->getGid()}"; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - final protected function _getDir (): string { |
|
| 41 | + final protected function _getDir(): string { |
|
| 42 | 42 | return 'tags'; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param array $filter |
| 47 | 47 | * @return Traversable|Task[] |
| 48 | 48 | */ |
| 49 | - public function getIterator (array $filter = Task::FILTER_INCOMPLETE) { |
|
| 49 | + public function getIterator(array $filter = Task::FILTER_INCOMPLETE) { |
|
| 50 | 50 | return $this->api->loadEach($this, Task::class, "{$this}/tasks", $filter); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param array $filter |
| 55 | 55 | * @return Task[] |
| 56 | 56 | */ |
| 57 | - public function getTasks (array $filter = Task::FILTER_INCOMPLETE) { |
|
| 57 | + public function getTasks(array $filter = Task::FILTER_INCOMPLETE) { |
|
| 58 | 58 | return iterator_to_array($this->getIterator($filter)); |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | \ No newline at end of file |