@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | const ASSIGN_TODAY = 'today'; |
72 | 72 | const ASSIGN_UPCOMING = 'upcoming'; |
73 | 73 | |
74 | - final public function __toString (): string { |
|
74 | + final public function __toString(): string { |
|
75 | 75 | return "tasks/{$this->getGid()}"; |
76 | 76 | } |
77 | 77 | |
78 | - final protected function _getDir (): string { |
|
78 | + final protected function _getDir(): string { |
|
79 | 79 | return 'tasks'; |
80 | 80 | } |
81 | 81 | |
82 | - protected function _getMap (): array { |
|
82 | + protected function _getMap(): array { |
|
83 | 83 | return [ |
84 | 84 | 'assignee' => User::class, |
85 | 85 | 'custom_fields' => CustomValues::class, |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param string $file |
101 | 101 | * @return Attachment |
102 | 102 | */ |
103 | - public function addAttachment (string $file) { |
|
103 | + public function addAttachment(string $file) { |
|
104 | 104 | /** @var Attachment $attachment */ |
105 | 105 | $attachment = $this->factory(Attachment::class, ['parent' => $this]); |
106 | 106 | return $attachment->upload($file); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param string $text |
114 | 114 | * @return Story |
115 | 115 | */ |
116 | - public function addComment (string $text) { |
|
116 | + public function addComment(string $text) { |
|
117 | 117 | return $this->newComment()->setText($text)->create(); |
118 | 118 | } |
119 | 119 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param Task[] $tasks |
125 | 125 | * @return $this |
126 | 126 | */ |
127 | - public function addDependencies (array $tasks) { |
|
127 | + public function addDependencies(array $tasks) { |
|
128 | 128 | $this->api->post("{$this}/addDependencies", ['dependents' => static::_getGids($tasks)]); |
129 | 129 | return $this; |
130 | 130 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param Task $task |
137 | 137 | * @return $this |
138 | 138 | */ |
139 | - public function addDependency (Task $task) { |
|
139 | + public function addDependency(Task $task) { |
|
140 | 140 | return $this->addDependencies([$task]); |
141 | 141 | } |
142 | 142 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param Task $task |
148 | 148 | * @return $this |
149 | 149 | */ |
150 | - public function addDependent (Task $task) { |
|
150 | + public function addDependent(Task $task) { |
|
151 | 151 | return $this->addDependents([$task]); |
152 | 152 | } |
153 | 153 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @param Task[] $tasks |
159 | 159 | * @return $this |
160 | 160 | */ |
161 | - public function addDependents (array $tasks) { |
|
161 | + public function addDependents(array $tasks) { |
|
162 | 162 | $this->api->post("{$this}/addDependents", ['dependents' => static::_getGids($tasks)]); |
163 | 163 | return $this; |
164 | 164 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param User $user |
170 | 170 | * @return $this |
171 | 171 | */ |
172 | - public function addFollower (User $user) { |
|
172 | + public function addFollower(User $user) { |
|
173 | 173 | return $this->addFollowers([$user]); |
174 | 174 | } |
175 | 175 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param User[] $users |
180 | 180 | * @return $this |
181 | 181 | */ |
182 | - public function addFollowers (array $users) { |
|
182 | + public function addFollowers(array $users) { |
|
183 | 183 | if ($this->hasGid()) { |
184 | 184 | $this->api->post("{$this}/addFollowers", ['followers' => static::_getGids($users)]); |
185 | 185 | $this->_merge('followers', $users); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param Tag $tag |
197 | 197 | * @return $this |
198 | 198 | */ |
199 | - public function addTag (Tag $tag) { |
|
199 | + public function addTag(Tag $tag) { |
|
200 | 200 | if ($this->hasGid()) { |
201 | 201 | $this->api->post("{$this}/addTag", ['tag' => $tag->getGid()]); |
202 | 202 | $this->_merge('tags', [$tag]); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @param Section $section |
214 | 214 | * @return $this |
215 | 215 | */ |
216 | - public function addToProject (Section $section) { |
|
216 | + public function addToProject(Section $section) { |
|
217 | 217 | $project = $section->getProject(); |
218 | 218 | if ($this->hasGid()) { |
219 | 219 | $this->api->post("{$this}/addProject", [ |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @param string $target |
248 | 248 | * @return TaskWebhook |
249 | 249 | */ |
250 | - public function addWebhook (string $target) { |
|
250 | + public function addWebhook(string $target) { |
|
251 | 251 | /** @var TaskWebhook $webhook */ |
252 | 252 | $webhook = $this->factory(TaskWebhook::class); |
253 | 253 | return $webhook->create($this, $target); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param string[] $include |
264 | 264 | * @return Job |
265 | 265 | */ |
266 | - public function duplicate (string $name, array $include) { |
|
266 | + public function duplicate(string $name, array $include) { |
|
267 | 267 | $remote = $this->api->post("{$this}/duplicate", [ |
268 | 268 | 'name' => $name, |
269 | 269 | 'include' => array_values($include) |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @depends after-create |
278 | 278 | * @return Attachment[] |
279 | 279 | */ |
280 | - public function getAttachments () { |
|
280 | + public function getAttachments() { |
|
281 | 281 | return $this->loadAll(Attachment::class, "{$this}/attachments"); |
282 | 282 | } |
283 | 283 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @depends after-create |
288 | 288 | * @return Story[] |
289 | 289 | */ |
290 | - public function getComments () { |
|
290 | + public function getComments() { |
|
291 | 291 | return array_values(array_filter($this->getStories(), function(Story $story) { |
292 | 292 | return $story->isComment(); |
293 | 293 | })); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @depends after-create |
300 | 300 | * @return Task[] |
301 | 301 | */ |
302 | - public function getDependencies () { |
|
302 | + public function getDependencies() { |
|
303 | 303 | return $this->loadAll(self::class, "{$this}/dependencies"); |
304 | 304 | } |
305 | 305 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @depends after-create |
310 | 310 | * @return Task[] |
311 | 311 | */ |
312 | - public function getDependents () { |
|
312 | + public function getDependents() { |
|
313 | 313 | return $this->loadAll(self::class, "{$this}/dependents"); |
314 | 314 | } |
315 | 315 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @param null|string $token |
321 | 321 | * @return TaskEvent[]|StoryEvent[] |
322 | 322 | */ |
323 | - public function getEvents (&$token) { |
|
323 | + public function getEvents(&$token) { |
|
324 | 324 | return $this->api->sync($this, $token); |
325 | 325 | } |
326 | 326 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @depends after-create |
331 | 331 | * @return Story[] |
332 | 332 | */ |
333 | - public function getStories () { |
|
333 | + public function getStories() { |
|
334 | 334 | return $this->loadAll(Story::class, "{$this}/stories"); |
335 | 335 | } |
336 | 336 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * @depends after-create |
341 | 341 | * @return Task[] |
342 | 342 | */ |
343 | - public function getSubTasks () { |
|
343 | + public function getSubTasks() { |
|
344 | 344 | return $this->loadAll(self::class, "{$this}/subtasks"); |
345 | 345 | } |
346 | 346 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @depends after-create |
351 | 351 | * @return string |
352 | 352 | */ |
353 | - public function getUrl (): string { |
|
353 | + public function getUrl(): string { |
|
354 | 354 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
355 | 355 | } |
356 | 356 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @depends after-create |
361 | 361 | * @return TaskWebhook[] |
362 | 362 | */ |
363 | - public function getWebhooks () { |
|
363 | + public function getWebhooks() { |
|
364 | 364 | return $this->loadAll(TaskWebhook::class, 'webhooks', [ |
365 | 365 | 'workspace' => $this->getWorkspace()->getGid(), |
366 | 366 | 'resource' => $this->getGid() |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return bool |
374 | 374 | */ |
375 | - public function isDiff (): bool { |
|
375 | + public function isDiff(): bool { |
|
376 | 376 | return parent::isDiff() or $this->hasCustomFields() && $this->getCustomFields()->isDiff(); |
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
380 | 380 | * @return bool |
381 | 381 | */ |
382 | - public function isRenderedAsSeparator (): bool { |
|
382 | + public function isRenderedAsSeparator(): bool { |
|
383 | 383 | return $this->_is('is_rendered_as_separator'); |
384 | 384 | } |
385 | 385 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @depends after-create |
390 | 390 | * @return Story |
391 | 391 | */ |
392 | - public function newComment () { |
|
392 | + public function newComment() { |
|
393 | 393 | /** @var Story $comment */ |
394 | 394 | $comment = $this->factory(Story::class, [ |
395 | 395 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @depends after-create |
404 | 404 | * @return Task |
405 | 405 | */ |
406 | - public function newSubTask () { |
|
406 | + public function newSubTask() { |
|
407 | 407 | /** @var Task $sub */ |
408 | 408 | $sub = $this->factory(self::class); |
409 | 409 | return $sub->setParent($this); |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | /** |
413 | 413 | * Marks `custom_fields` clean. |
414 | 414 | */ |
415 | - protected function onUpdate (): void { |
|
415 | + protected function onUpdate(): void { |
|
416 | 416 | if ($this->hasCustomFields()) { |
417 | 417 | $this->getCustomFields()->diff = []; |
418 | 418 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @param Task[] $tasks |
426 | 426 | * @return $this |
427 | 427 | */ |
428 | - public function removeDependencies (array $tasks) { |
|
428 | + public function removeDependencies(array $tasks) { |
|
429 | 429 | $this->api->post("{$this}/removeDependencies", ['dependencies' => static::_getGids($tasks)]); |
430 | 430 | return $this; |
431 | 431 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * @param Task $task |
438 | 438 | * @return $this |
439 | 439 | */ |
440 | - public function removeDependency (Task $task) { |
|
440 | + public function removeDependency(Task $task) { |
|
441 | 441 | return $this->removeDependencies([$task]); |
442 | 442 | } |
443 | 443 | |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * @param Task $task |
449 | 449 | * @return $this |
450 | 450 | */ |
451 | - public function removeDependent (Task $task) { |
|
451 | + public function removeDependent(Task $task) { |
|
452 | 452 | return $this->removeDependents([$task]); |
453 | 453 | } |
454 | 454 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * @param Task[] $tasks |
460 | 460 | * @return $this |
461 | 461 | */ |
462 | - public function removeDependents (array $tasks) { |
|
462 | + public function removeDependents(array $tasks) { |
|
463 | 463 | $this->api->post("{$this}/removeDependents", ['dependents' => static::_getGids($tasks)]); |
464 | 464 | return $this; |
465 | 465 | } |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @param User $user |
471 | 471 | * @return $this |
472 | 472 | */ |
473 | - public function removeFollower (User $user) { |
|
473 | + public function removeFollower(User $user) { |
|
474 | 474 | return $this->removeFollowers([$user]); |
475 | 475 | } |
476 | 476 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * @param User[] $users |
481 | 481 | * @return $this |
482 | 482 | */ |
483 | - public function removeFollowers (array $users) { |
|
483 | + public function removeFollowers(array $users) { |
|
484 | 484 | if ($this->hasGid()) { |
485 | 485 | $this->api->post("{$this}/removeFollowers", ['followers' => static::_getGids($users)]); |
486 | 486 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @param Project $project |
495 | 495 | * @return $this |
496 | 496 | */ |
497 | - public function removeFromProject (Project $project) { |
|
497 | + public function removeFromProject(Project $project) { |
|
498 | 498 | $gid = $project->getGid(); |
499 | 499 | if ($this->hasGid()) { |
500 | 500 | $this->api->post("{$this}/removeProject", ['project' => $gid]); |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | * @param Tag $tag |
514 | 514 | * @return $this |
515 | 515 | */ |
516 | - public function removeTag (Tag $tag) { |
|
516 | + public function removeTag(Tag $tag) { |
|
517 | 517 | if ($this->hasGid()) { |
518 | 518 | $this->api->post("{$this}/removeTag", ['tag' => $tag->getGid()]); |
519 | 519 | } |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * @param null|Task $parent |
528 | 528 | * @return $this |
529 | 529 | */ |
530 | - public function setParent (?self $parent) { |
|
530 | + public function setParent(?self $parent) { |
|
531 | 531 | if ($this->hasGid()) { |
532 | 532 | $this->api->post("{$this}/setParent", ['parent' => $parent ? $parent->getGid() : null]); |
533 | 533 | $this->data['parent'] = $parent; |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @param bool $flag |
543 | 543 | * @return $this |
544 | 544 | */ |
545 | - public function setRenderedAsSeparator (bool $flag) { |
|
545 | + public function setRenderedAsSeparator(bool $flag) { |
|
546 | 546 | return $this->_set('is_rendered_as_separator', $flag); |
547 | 547 | } |
548 | 548 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | protected $optionNames = []; |
36 | 36 | |
37 | - public function __construct (Task $task, array $fields) { |
|
37 | + public function __construct(Task $task, array $fields) { |
|
38 | 38 | parent::__construct($task); |
39 | 39 | foreach ($fields as $field) { |
40 | 40 | $gid = $this->gids[$field['name']] = $field['gid']; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @return int |
56 | 56 | */ |
57 | - public function count () { |
|
57 | + public function count() { |
|
58 | 58 | return count($this->data); |
59 | 59 | } |
60 | 60 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param string $fieldName |
63 | 63 | * @return null|string |
64 | 64 | */ |
65 | - public function getGid (string $fieldName) { |
|
65 | + public function getGid(string $fieldName) { |
|
66 | 66 | return $this->gids[$fieldName] ?? null; |
67 | 67 | } |
68 | 68 | |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return string[] |
73 | 73 | */ |
74 | - public function getGids () { |
|
74 | + public function getGids() { |
|
75 | 75 | return $this->gids; |
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @return Traversable |
80 | 80 | */ |
81 | - public function getIterator () { |
|
81 | + public function getIterator() { |
|
82 | 82 | return new ArrayIterator($this->data); |
83 | 83 | } |
84 | 84 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param string $fieldGid |
87 | 87 | * @return null|string |
88 | 88 | */ |
89 | - public function getName (string $fieldGid): ?string { |
|
89 | + public function getName(string $fieldGid): ?string { |
|
90 | 90 | return array_search($fieldGid, $this->gids) ?: null; |
91 | 91 | } |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return string[] |
97 | 97 | */ |
98 | - public function getNames () { |
|
98 | + public function getNames() { |
|
99 | 99 | return array_flip($this->gids); |
100 | 100 | } |
101 | 101 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param string $optionName |
105 | 105 | * @return null|string |
106 | 106 | */ |
107 | - public function getOptionGid (string $enumGid, string $optionName) { |
|
107 | + public function getOptionGid(string $enumGid, string $optionName) { |
|
108 | 108 | return array_search($optionName, $this->optionNames[$enumGid]) ?: null; |
109 | 109 | } |
110 | 110 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param string $enumGid |
115 | 115 | * @return string[] |
116 | 116 | */ |
117 | - public function getOptionGids (string $enumGid) { |
|
117 | + public function getOptionGids(string $enumGid) { |
|
118 | 118 | return array_flip($this->optionNames[$enumGid]); |
119 | 119 | } |
120 | 120 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param string $optionGid |
124 | 124 | * @return null|string |
125 | 125 | */ |
126 | - public function getOptionName (string $enumGid, string $optionGid): ?string { |
|
126 | + public function getOptionName(string $enumGid, string $optionGid): ?string { |
|
127 | 127 | return $this->optionNames[$enumGid][$optionGid] ?? null; |
128 | 128 | } |
129 | 129 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param string $enumGid |
134 | 134 | * @return string[] |
135 | 135 | */ |
136 | - public function getOptionNames (string $enumGid) { |
|
136 | + public function getOptionNames(string $enumGid) { |
|
137 | 137 | return $this->optionNames[$enumGid]; |
138 | 138 | } |
139 | 139 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param string $fieldGid |
142 | 142 | * @return null|number|string |
143 | 143 | */ |
144 | - public function getValue (string $fieldGid) { |
|
144 | + public function getValue(string $fieldGid) { |
|
145 | 145 | return $this->data[$fieldGid] ?? null; |
146 | 146 | } |
147 | 147 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param string $fieldGid |
150 | 150 | * @return bool |
151 | 151 | */ |
152 | - public function offsetExists ($fieldGid) { |
|
152 | + public function offsetExists($fieldGid) { |
|
153 | 153 | return array_key_exists($fieldGid, $this->data); |
154 | 154 | } |
155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string $fieldGid |
158 | 158 | * @return null|number|string |
159 | 159 | */ |
160 | - public function offsetGet ($fieldGid) { |
|
160 | + public function offsetGet($fieldGid) { |
|
161 | 161 | return $this->getValue($fieldGid); |
162 | 162 | } |
163 | 163 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param string $fieldGid |
166 | 166 | * @param null|number|string $value |
167 | 167 | */ |
168 | - public function offsetSet ($fieldGid, $value) { |
|
168 | + public function offsetSet($fieldGid, $value) { |
|
169 | 169 | $this->setValue($fieldGid, $value); |
170 | 170 | } |
171 | 171 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @param string $fieldGid |
176 | 176 | */ |
177 | - public function offsetUnset ($fieldGid) { |
|
177 | + public function offsetUnset($fieldGid) { |
|
178 | 178 | $this->setValue($fieldGid, null); |
179 | 179 | } |
180 | 180 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param null|number|string $value |
184 | 184 | * @return $this |
185 | 185 | */ |
186 | - public function setValue (string $fieldGid, $value) { |
|
186 | + public function setValue(string $fieldGid, $value) { |
|
187 | 187 | $this->data[$fieldGid] = $value; |
188 | 188 | $this->diff[$fieldGid] = true; |
189 | 189 | return $this; |
@@ -41,11 +41,9 @@ |
||
41 | 41 | if ($field['type'] === CustomField::TYPE_ENUM) { |
42 | 42 | $this->optionNames[$gid] = array_column($field['enum_options'], 'name', 'gid'); |
43 | 43 | $this->data[$gid] = $field['enum_value']['gid']; |
44 | - } |
|
45 | - elseif ($field['type'] === CustomField::TYPE_TEXT) { |
|
44 | + } elseif ($field['type'] === CustomField::TYPE_TEXT) { |
|
46 | 45 | $this->data[$gid] = $field['text_value']; |
47 | - } |
|
48 | - elseif ($field['type'] === CustomField::TYPE_NUMBER) { |
|
46 | + } elseif ($field['type'] === CustomField::TYPE_NUMBER) { |
|
49 | 47 | $this->data[$gid] = $field['number_value']; |
50 | 48 | } |
51 | 49 | } |
@@ -31,15 +31,15 @@ discard block |
||
31 | 31 | |
32 | 32 | const TYPE = 'portfolio'; |
33 | 33 | |
34 | - final public function __toString (): string { |
|
34 | + final public function __toString(): string { |
|
35 | 35 | return "portfolios/{$this->getGid()}"; |
36 | 36 | } |
37 | 37 | |
38 | - final protected function _getDir (): string { |
|
38 | + final protected function _getDir(): string { |
|
39 | 39 | return 'portfolios'; |
40 | 40 | } |
41 | 41 | |
42 | - protected function _getMap (): array { |
|
42 | + protected function _getMap(): array { |
|
43 | 43 | return [ |
44 | 44 | 'created_by' => User::class, |
45 | 45 | 'custom_fields' => [CustomField::class], |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param Project $item |
55 | 55 | * @return $this |
56 | 56 | */ |
57 | - public function addItem (Project $item) { |
|
57 | + public function addItem(Project $item) { |
|
58 | 58 | $this->api->post("{$this}/addItem", ['item' => $item->getGid()]); |
59 | 59 | return $this; |
60 | 60 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param User $user |
64 | 64 | * @return $this |
65 | 65 | */ |
66 | - public function addMember (User $user) { |
|
66 | + public function addMember(User $user) { |
|
67 | 67 | return $this->addMembers([$user]); |
68 | 68 | } |
69 | 69 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param User[] $users |
72 | 72 | * @return $this |
73 | 73 | */ |
74 | - public function addMembers (array $users) { |
|
74 | + public function addMembers(array $users) { |
|
75 | 75 | if ($this->hasGid()) { |
76 | 76 | $this->api->post("{$this}/addMembers", ['members' => static::_getGids($users)]); |
77 | 77 | $this->_merge('members', $users); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @depends after-create |
87 | 87 | * @return Project[] |
88 | 88 | */ |
89 | - public function getItems () { |
|
89 | + public function getItems() { |
|
90 | 90 | return $this->loadAll(Project::class, "{$this}/items"); |
91 | 91 | } |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param Project $item |
96 | 96 | * @return $this |
97 | 97 | */ |
98 | - public function removeItem (Project $item) { |
|
98 | + public function removeItem(Project $item) { |
|
99 | 99 | $this->api->post("{$this}/removeItem", ['item' => $item->getGid()]); |
100 | 100 | return $this; |
101 | 101 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param User $user |
105 | 105 | * @return $this |
106 | 106 | */ |
107 | - public function removeMember (User $user) { |
|
107 | + public function removeMember(User $user) { |
|
108 | 108 | return $this->removeMembers([$user]); |
109 | 109 | } |
110 | 110 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param User[] $users |
113 | 113 | * @return $this |
114 | 114 | */ |
115 | - public function removeMembers (array $users) { |
|
115 | + public function removeMembers(array $users) { |
|
116 | 116 | if ($this->hasGid()) { |
117 | 117 | $this->api->post("{$this}/removeMembers", ['members' => static::_getGids($users)]); |
118 | 118 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param Api|Data $caller |
31 | 31 | * @param array $data |
32 | 32 | */ |
33 | - public function __construct ($caller, array $data = []) { |
|
33 | + public function __construct($caller, array $data = []) { |
|
34 | 34 | $this->api = $caller instanceof self ? $caller->api : $caller; |
35 | 35 | $this->_setData($data); |
36 | 36 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @param array $args |
47 | 47 | * @return mixed |
48 | 48 | */ |
49 | - public function __call (string $method, array $args) { |
|
49 | + public function __call(string $method, array $args) { |
|
50 | 50 | static $cache = []; |
51 | - if (!$call =& $cache[$method]) { |
|
51 | + if (!$call = & $cache[$method]) { |
|
52 | 52 | preg_match('/^(get|has|is|set)(.+)$/', $method, $call); |
53 | 53 | $call[1] = '_' . $call[1]; |
54 | 54 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | return $this->{$call[1]}($call[2], ...$args); |
59 | 59 | } |
60 | 60 | |
61 | - public function __debugInfo (): array { |
|
61 | + public function __debugInfo(): array { |
|
62 | 62 | return $this->data; |
63 | 63 | } |
64 | 64 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param string $key |
71 | 71 | * @return mixed |
72 | 72 | */ |
73 | - protected function _get (string $key) { |
|
73 | + protected function _get(string $key) { |
|
74 | 74 | return $this->data[$key] ?? null; |
75 | 75 | } |
76 | 76 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return array |
84 | 84 | */ |
85 | - protected function _getMap (): array { |
|
85 | + protected function _getMap(): array { |
|
86 | 86 | return []; |
87 | 87 | } |
88 | 88 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param null|self|array $value |
92 | 92 | * @return null|Data|Data[] |
93 | 93 | */ |
94 | - protected function _getMapped ($class, $value) { |
|
94 | + protected function _getMapped($class, $value) { |
|
95 | 95 | // use empty|Data|Data[] as-is |
96 | 96 | if (!$value or $value instanceof self or current($value) instanceof self) { |
97 | 97 | return $value; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param string $key |
130 | 130 | * @return bool |
131 | 131 | */ |
132 | - protected function _has (string $key): bool { |
|
132 | + protected function _has(string $key): bool { |
|
133 | 133 | $value = $this->_get($key); |
134 | 134 | if (isset($value)) { |
135 | 135 | if (is_countable($value)) { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param string $key |
153 | 153 | * @return bool |
154 | 154 | */ |
155 | - protected function _is (string $key): bool { |
|
155 | + protected function _is(string $key): bool { |
|
156 | 156 | return !empty($this->_get($key)); |
157 | 157 | } |
158 | 158 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param mixed $value |
166 | 166 | * @return $this |
167 | 167 | */ |
168 | - protected function _set (string $key, $value) { |
|
168 | + protected function _set(string $key, $value) { |
|
169 | 169 | $this->data[$key] = $value; |
170 | 170 | $this->diff[$key] = true; |
171 | 171 | return $this; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param array $data |
178 | 178 | * @return $this |
179 | 179 | */ |
180 | - protected function _setData (array $data) { |
|
180 | + protected function _setData(array $data) { |
|
181 | 181 | $map = $this->_getMap(); |
182 | 182 | /** @var null|self|array $value */ |
183 | 183 | foreach (array_intersect_key($data, $map) as $key => $value) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param array $data |
196 | 196 | * @return mixed |
197 | 197 | */ |
198 | - final protected function factory (string $class, array $data = []) { |
|
198 | + final protected function factory(string $class, array $data = []) { |
|
199 | 199 | return $this->api->factory($class, $this, $data); |
200 | 200 | } |
201 | 201 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return array |
206 | 206 | */ |
207 | - public function getDiff (): array { |
|
207 | + public function getDiff(): array { |
|
208 | 208 | $convert = function($each) use (&$convert) { |
209 | 209 | // convert existing entities to gids |
210 | 210 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return bool |
231 | 231 | */ |
232 | - public function isDiff (): bool { |
|
232 | + public function isDiff(): bool { |
|
233 | 233 | return (bool)$this->diff; |
234 | 234 | } |
235 | 235 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @see toArray() |
238 | 238 | * @return array |
239 | 239 | */ |
240 | - public function jsonSerialize (): array { |
|
240 | + public function jsonSerialize(): array { |
|
241 | 241 | return $this->toArray(); |
242 | 242 | } |
243 | 243 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @param array $query |
252 | 252 | * @return null|mixed|AbstractEntity |
253 | 253 | */ |
254 | - final protected function load (string $class, string $path, array $query = []) { |
|
254 | + final protected function load(string $class, string $path, array $query = []) { |
|
255 | 255 | return $this->api->load($class, $this, $path, $query); |
256 | 256 | } |
257 | 257 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @param int $pages |
267 | 267 | * @return array|AbstractEntity[] |
268 | 268 | */ |
269 | - final protected function loadAll (string $class, string $path, array $query = [], int $pages = 0) { |
|
269 | + final protected function loadAll(string $class, string $path, array $query = [], int $pages = 0) { |
|
270 | 270 | return $this->api->loadAll($class, $this, $path, $query, $pages); |
271 | 271 | } |
272 | 272 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - public function serialize (): string { |
|
280 | + public function serialize(): string { |
|
281 | 281 | return serialize($this->toArray()); |
282 | 282 | } |
283 | 283 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return array |
288 | 288 | */ |
289 | - public function toArray (): array { |
|
289 | + public function toArray(): array { |
|
290 | 290 | if (!$this->api) { |
291 | 291 | return $this->data; |
292 | 292 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @param $serialized |
314 | 314 | */ |
315 | - public function unserialize ($serialized): void { |
|
315 | + public function unserialize($serialized): void { |
|
316 | 316 | $this->data = unserialize($serialized); |
317 | 317 | } |
318 | 318 | } |
319 | 319 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | * Stub. |
17 | 17 | */ |
18 | - protected function onUpdate (): void { |
|
18 | + protected function onUpdate(): void { |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return $this |
25 | 25 | */ |
26 | - public function update () { |
|
26 | + public function update() { |
|
27 | 27 | if ($this->isDiff()) { |
28 | 28 | /** @var Api $api */ |
29 | 29 | $api = $this->api; |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | const LAYOUT_BOARD = 'board'; |
58 | 58 | const LAYOUT_LIST = 'list'; |
59 | 59 | |
60 | - final public function __toString (): string { |
|
60 | + final public function __toString(): string { |
|
61 | 61 | return "projects/{$this->getGid()}"; |
62 | 62 | } |
63 | 63 | |
64 | - final protected function _getDir (): string { |
|
64 | + final protected function _getDir(): string { |
|
65 | 65 | return 'projects'; |
66 | 66 | } |
67 | 67 | |
68 | - protected function _getMap (): array { |
|
68 | + protected function _getMap(): array { |
|
69 | 69 | return [ |
70 | 70 | 'current_status' => Status::class, |
71 | 71 | 'custom_fields' => [CustomField::class], |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param User $user |
83 | 83 | * @return $this |
84 | 84 | */ |
85 | - public function addMember (User $user) { |
|
85 | + public function addMember(User $user) { |
|
86 | 86 | return $this->addMembers([$user]); |
87 | 87 | } |
88 | 88 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param User[] $users |
92 | 92 | * @return $this |
93 | 93 | */ |
94 | - public function addMembers (array $users) { |
|
94 | + public function addMembers(array $users) { |
|
95 | 95 | $this->api->post("{$this}/addMembers", ['members' => static::_getGids($users)]); |
96 | 96 | $this->_merge('members', $users); |
97 | 97 | return $this; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param string $target |
103 | 103 | * @return ProjectWebhook |
104 | 104 | */ |
105 | - public function addWebhook (string $target) { |
|
105 | + public function addWebhook(string $target) { |
|
106 | 106 | /** @var ProjectWebhook $webhook */ |
107 | 107 | $webhook = $this->factory(ProjectWebhook::class); |
108 | 108 | return $webhook->create($this, $target); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param array $schedule |
128 | 128 | * @return Job |
129 | 129 | */ |
130 | - public function duplicate (string $name, array $include, Team $team = null, array $schedule = []) { |
|
130 | + public function duplicate(string $name, array $include, Team $team = null, array $schedule = []) { |
|
131 | 131 | $data = ['name' => $name]; |
132 | 132 | if ($team) { |
133 | 133 | $data['team'] = $team->getGid(); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param null|string $token |
150 | 150 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
151 | 151 | */ |
152 | - public function getEvents (&$token) { |
|
152 | + public function getEvents(&$token) { |
|
153 | 153 | return $this->api->sync($this, $token); |
154 | 154 | } |
155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @depends after-create |
158 | 158 | * @return Section[] |
159 | 159 | */ |
160 | - public function getSections () { |
|
160 | + public function getSections() { |
|
161 | 161 | return $this->loadAll(Section::class, "{$this}/sections"); |
162 | 162 | } |
163 | 163 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @depends after-create |
166 | 166 | * @return Status[] |
167 | 167 | */ |
168 | - public function getStatuses () { |
|
168 | + public function getStatuses() { |
|
169 | 169 | return $this->loadAll(Status::class, "{$this}/project_statuses"); |
170 | 170 | } |
171 | 171 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param array $query |
175 | 175 | * @return Task[] |
176 | 176 | */ |
177 | - public function getTasks (array $query = []) { |
|
177 | + public function getTasks(array $query = []) { |
|
178 | 178 | $query['project'] = $this->getGid(); |
179 | 179 | return $this->loadAll(Task::class, "tasks", $query); |
180 | 180 | } |
@@ -183,25 +183,25 @@ discard block |
||
183 | 183 | * @depends after-create |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - public function getUrl (): string { |
|
186 | + public function getUrl(): string { |
|
187 | 187 | return "https://app.asana.com/0/{$this->getGid()}"; |
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * @return ProjectWebhook[] |
192 | 192 | */ |
193 | - public function getWebhooks () { |
|
193 | + public function getWebhooks() { |
|
194 | 194 | return $this->loadAll(ProjectWebhook::class, 'webhooks', [ |
195 | 195 | 'workspace' => $this->getWorkspace()->getGid(), |
196 | 196 | 'resource' => $this->getGid() |
197 | 197 | ]); |
198 | 198 | } |
199 | 199 | |
200 | - public function isBoard (): bool { |
|
200 | + public function isBoard(): bool { |
|
201 | 201 | return $this->getLayout() === self::LAYOUT_BOARD; |
202 | 202 | } |
203 | 203 | |
204 | - public function isList (): bool { |
|
204 | + public function isList(): bool { |
|
205 | 205 | return $this->getLayout() === self::LAYOUT_LIST; |
206 | 206 | } |
207 | 207 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @depends after-create |
210 | 210 | * @return Section |
211 | 211 | */ |
212 | - public function newSection () { |
|
212 | + public function newSection() { |
|
213 | 213 | return $this->factory(Section::class, ['projects' => [$this]]); |
214 | 214 | } |
215 | 215 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @depends after-create |
218 | 218 | * @return Status |
219 | 219 | */ |
220 | - public function newStatus () { |
|
220 | + public function newStatus() { |
|
221 | 221 | return $this->factory(Status::class); |
222 | 222 | } |
223 | 223 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @depends after-create |
228 | 228 | * @return Task |
229 | 229 | */ |
230 | - public function newTask () { |
|
230 | + public function newTask() { |
|
231 | 231 | return $this->getSections()[0]->newTask(); |
232 | 232 | } |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param User $user |
237 | 237 | * @return $this |
238 | 238 | */ |
239 | - public function removeMember (User $user) { |
|
239 | + public function removeMember(User $user) { |
|
240 | 240 | return $this->removeMembers([$user]); |
241 | 241 | } |
242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param User[] $users |
246 | 246 | * @return $this |
247 | 247 | */ |
248 | - public function removeMembers (array $users) { |
|
248 | + public function removeMembers(array $users) { |
|
249 | 249 | $this->api->post("{$this}/removeMembers", ['members' => static::_getGids($users)]); |
250 | 250 | $this->_remove('members', $users); |
251 | 251 | return $this; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param null|Team $team |
257 | 257 | * @return $this |
258 | 258 | */ |
259 | - public function setTeam (?Team $team) { |
|
259 | + public function setTeam(?Team $team) { |
|
260 | 260 | assert(!$this->hasGid()); |
261 | 261 | if ($team and !$this->hasWorkspace()) { |
262 | 262 | $this->setWorkspace($team->getOrganization()); |