@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | 'project' => Project::class |
29 | 29 | ]; |
30 | 30 | |
31 | - final public function __toString (): string { |
|
31 | + final public function __toString(): string { |
|
32 | 32 | return "sections/{$this->getGid()}"; |
33 | 33 | } |
34 | 34 | |
35 | - final protected function _getDir (): string { |
|
35 | + final protected function _getDir(): string { |
|
36 | 36 | return "{$this->getProject()}/sections"; |
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @return Task[] |
41 | 41 | */ |
42 | - public function getTasks () { |
|
42 | + public function getTasks() { |
|
43 | 43 | return $this->loadAll(Task::class, 'tasks', ['section' => $this->getGid()]); |
44 | 44 | } |
45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @depends after-create |
50 | 50 | * @return Task |
51 | 51 | */ |
52 | - public function newTask () { |
|
52 | + public function newTask() { |
|
53 | 53 | /** @var Task $task */ |
54 | 54 | $task = $this->factory(Task::class); |
55 | 55 | return $task->addToProject($this); |
@@ -45,23 +45,23 @@ discard block |
||
45 | 45 | 'task' => Task::class |
46 | 46 | ]; |
47 | 47 | |
48 | - final public function __toString (): string { |
|
48 | + final public function __toString(): string { |
|
49 | 49 | return "stories/{$this->getGid()}"; |
50 | 50 | } |
51 | 51 | |
52 | - final protected function _getDir (): string { |
|
52 | + final protected function _getDir(): string { |
|
53 | 53 | return "{$this->getTask()}/stories"; |
54 | 54 | } |
55 | 55 | |
56 | - final public function isComment (): bool { |
|
56 | + final public function isComment(): bool { |
|
57 | 57 | return $this->getResourceSubtype() === self::TYPE_COMMENT_ADDED; |
58 | 58 | } |
59 | 59 | |
60 | - public function isEdited (): bool { |
|
60 | + public function isEdited(): bool { |
|
61 | 61 | return $this->_is('is_edited'); |
62 | 62 | } |
63 | 63 | |
64 | - public function isPinned (): bool { |
|
64 | + public function isPinned(): bool { |
|
65 | 65 | return $this->_is('is_pinned'); |
66 | 66 | } |
67 | 67 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param bool $pinned |
70 | 70 | * @return $this |
71 | 71 | */ |
72 | - public function setPinned (bool $pinned) { |
|
72 | + public function setPinned(bool $pinned) { |
|
73 | 73 | return $this->_set('is_pinned', $pinned); |
74 | 74 | } |
75 | 75 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | 'parent' => Task::class |
33 | 33 | ]; |
34 | 34 | |
35 | - final public function __toString (): string { |
|
35 | + final public function __toString(): string { |
|
36 | 36 | return "attachments/{$this->getGid()}"; |
37 | 37 | } |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string $file |
43 | 43 | * @return $this |
44 | 44 | */ |
45 | - public function upload (string $file) { |
|
45 | + public function upload(string $file) { |
|
46 | 46 | // api returns compact version. reload. |
47 | 47 | $remote = $this->api->upload("{$this->getParent()}/attachments", $file); |
48 | 48 | $this->data['gid'] = $remote['gid']; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | 'organization' => Workspace::class |
26 | 26 | ]; |
27 | 27 | |
28 | - final public function __toString (): string { |
|
28 | + final public function __toString(): string { |
|
29 | 29 | return "teams/{$this->getGid()}"; |
30 | 30 | } |
31 | 31 | |
@@ -33,19 +33,19 @@ discard block |
||
33 | 33 | * @param User $user |
34 | 34 | * @return $this |
35 | 35 | */ |
36 | - public function addUser (User $user) { |
|
36 | + public function addUser(User $user) { |
|
37 | 37 | $this->api->post("{$this}/addUser", ['user' => $user->getGid()]); |
38 | 38 | return $this; |
39 | 39 | } |
40 | 40 | |
41 | - public function getUrl (): string { |
|
41 | + public function getUrl(): string { |
|
42 | 42 | return "https://app.asana.com/0/{$this->getGid()}/overview"; |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @return User[] |
47 | 47 | */ |
48 | - public function getUsers () { |
|
48 | + public function getUsers() { |
|
49 | 49 | return $this->loadAll(User::class, "{$this}/users"); |
50 | 50 | } |
51 | 51 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param User $user |
54 | 54 | * @return $this |
55 | 55 | */ |
56 | - public function removeUser (User $user) { |
|
56 | + public function removeUser(User $user) { |
|
57 | 57 | $this->api->post("{$this}/removeUser", ['user' => $user->getGid()]); |
58 | 58 | return $this; |
59 | 59 | } |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | 'organization' => Workspace::class |
34 | 34 | ]; |
35 | 35 | |
36 | - final public function __toString (): string { |
|
36 | + final public function __toString(): string { |
|
37 | 37 | return "organization_exports/{$this->getGid()}"; |
38 | 38 | } |
39 | 39 | |
40 | - final protected function _getDir (): string { |
|
40 | + final protected function _getDir(): string { |
|
41 | 41 | return "organization_exports"; |
42 | 42 | } |
43 | 43 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param Workspace $organization |
46 | 46 | * @return $this |
47 | 47 | */ |
48 | - public function create (Workspace $organization) { |
|
48 | + public function create(Workspace $organization) { |
|
49 | 49 | $this->_set('organization', $organization); |
50 | 50 | return $this->_create(); |
51 | 51 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return bool |
57 | 57 | */ |
58 | - public function isActive (): bool { |
|
58 | + public function isActive(): bool { |
|
59 | 59 | return $this->getState() === self::STATE_ACTIVE; |
60 | 60 | } |
61 | 61 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return bool |
66 | 66 | */ |
67 | - public function isDone (): bool { |
|
67 | + public function isDone(): bool { |
|
68 | 68 | return $this->isSuccessful() or $this->isFailed(); |
69 | 69 | } |
70 | 70 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return bool |
75 | 75 | */ |
76 | - public function isFailed (): bool { |
|
76 | + public function isFailed(): bool { |
|
77 | 77 | return $this->getState() === self::STATE_FAIL; |
78 | 78 | } |
79 | 79 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return bool |
84 | 84 | */ |
85 | - public function isQueued (): bool { |
|
85 | + public function isQueued(): bool { |
|
86 | 86 | return $this->getState() === self::STATE_QUEUED; |
87 | 87 | } |
88 | 88 | |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return bool |
93 | 93 | */ |
94 | - public function isSuccessful (): bool { |
|
94 | + public function isSuccessful(): bool { |
|
95 | 95 | return $this->getState() === self::STATE_SUCCESS; |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Sleeps and reloads "every few minutes" until the export completes successfully or fails. |
100 | 100 | */ |
101 | - public function wait () { |
|
101 | + public function wait() { |
|
102 | 102 | while (!$this->isDone()) { |
103 | 103 | sleep(240); |
104 | 104 | $this->reload(); |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | 'workspace' => Workspace::class |
40 | 40 | ]; |
41 | 41 | |
42 | - final public function __toString (): string { |
|
42 | + final public function __toString(): string { |
|
43 | 43 | return "portfolios/{$this->getGid()}"; |
44 | 44 | } |
45 | 45 | |
46 | - final protected function _getDir (): string { |
|
46 | + final protected function _getDir(): string { |
|
47 | 47 | return 'portfolios'; |
48 | 48 | } |
49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param Project $item |
53 | 53 | * @return $this |
54 | 54 | */ |
55 | - public function addItem (Project $item) { |
|
55 | + public function addItem(Project $item) { |
|
56 | 56 | $this->api->post("{$this}/addItem", ['item' => $item->getGid()]); |
57 | 57 | return $this; |
58 | 58 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param User $user |
62 | 62 | * @return $this |
63 | 63 | */ |
64 | - public function addMember (User $user) { |
|
64 | + public function addMember(User $user) { |
|
65 | 65 | return $this->addMembers([$user]); |
66 | 66 | } |
67 | 67 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param User[] $users |
70 | 70 | * @return $this |
71 | 71 | */ |
72 | - public function addMembers (array $users) { |
|
72 | + public function addMembers(array $users) { |
|
73 | 73 | if ($this->hasGid()) { |
74 | 74 | $this->api->post("{$this}/addMembers", ['members' => array_column($users, 'gid')]); |
75 | 75 | $this->_merge('members', $users); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @depends after-create |
85 | 85 | * @return Project[] |
86 | 86 | */ |
87 | - public function getItems () { |
|
87 | + public function getItems() { |
|
88 | 88 | return $this->loadAll(Project::class, "{$this}/items"); |
89 | 89 | } |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param Project $item |
94 | 94 | * @return $this |
95 | 95 | */ |
96 | - public function removeItem (Project $item) { |
|
96 | + public function removeItem(Project $item) { |
|
97 | 97 | $this->api->post("{$this}/removeItem", ['item' => $item->getGid()]); |
98 | 98 | return $this; |
99 | 99 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param User $user |
103 | 103 | * @return $this |
104 | 104 | */ |
105 | - public function removeMember (User $user) { |
|
105 | + public function removeMember(User $user) { |
|
106 | 106 | return $this->removeMembers([$user]); |
107 | 107 | } |
108 | 108 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param User[] $users |
111 | 111 | * @return $this |
112 | 112 | */ |
113 | - public function removeMembers (array $users) { |
|
113 | + public function removeMembers(array $users) { |
|
114 | 114 | if ($this->hasGid()) { |
115 | 115 | $this->api->post("{$this}/removeMembers", ['members' => array_column($users, 'gid')]); |
116 | 116 | } |
@@ -73,8 +73,7 @@ |
||
73 | 73 | if ($this->hasGid()) { |
74 | 74 | $this->api->post("{$this}/addMembers", ['members' => array_column($users, 'gid')]); |
75 | 75 | $this->_merge('members', $users); |
76 | - } |
|
77 | - else { |
|
76 | + } else { |
|
78 | 77 | $this->_merge('members', $users, true); |
79 | 78 | } |
80 | 79 | return $this; |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | 'workspace' => Workspace::class |
68 | 68 | ]; |
69 | 69 | |
70 | - final public function __toString (): string { |
|
70 | + final public function __toString(): string { |
|
71 | 71 | return "projects/{$this->getGid()}"; |
72 | 72 | } |
73 | 73 | |
74 | - final protected function _getDir (): string { |
|
74 | + final protected function _getDir(): string { |
|
75 | 75 | return 'projects'; |
76 | 76 | } |
77 | 77 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param User $user |
81 | 81 | * @return $this |
82 | 82 | */ |
83 | - public function addMember (User $user) { |
|
83 | + public function addMember(User $user) { |
|
84 | 84 | return $this->addMembers([$user]); |
85 | 85 | } |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @param User[] $users |
90 | 90 | * @return $this |
91 | 91 | */ |
92 | - public function addMembers (array $users) { |
|
92 | + public function addMembers(array $users) { |
|
93 | 93 | $this->api->post("{$this}/addMembers", ['members' => array_column($users, 'gid')]); |
94 | 94 | $this->_merge('members', $users); |
95 | 95 | return $this; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param string $target |
101 | 101 | * @return ProjectWebhook |
102 | 102 | */ |
103 | - public function addWebhook (string $target) { |
|
103 | + public function addWebhook(string $target) { |
|
104 | 104 | /** @var ProjectWebhook $webhook */ |
105 | 105 | $webhook = $this->factory(ProjectWebhook::class); |
106 | 106 | return $webhook->create($this, $target); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param array $schedule |
126 | 126 | * @return Job |
127 | 127 | */ |
128 | - public function duplicate (string $name, array $include, Team $team = null, array $schedule = []) { |
|
128 | + public function duplicate(string $name, array $include, Team $team = null, array $schedule = []) { |
|
129 | 129 | $data = ['name' => $name]; |
130 | 130 | if ($team) { |
131 | 131 | $data['team'] = $team->getGid(); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param null|string $token |
148 | 148 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
149 | 149 | */ |
150 | - public function getEvents (&$token) { |
|
150 | + public function getEvents(&$token) { |
|
151 | 151 | return $this->api->sync($this, $token); |
152 | 152 | } |
153 | 153 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @depends after-create |
156 | 156 | * @return Section[] |
157 | 157 | */ |
158 | - public function getSections () { |
|
158 | + public function getSections() { |
|
159 | 159 | return $this->loadAll(Section::class, "{$this}/sections"); |
160 | 160 | } |
161 | 161 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @depends after-create |
164 | 164 | * @return Status[] |
165 | 165 | */ |
166 | - public function getStatuses () { |
|
166 | + public function getStatuses() { |
|
167 | 167 | return $this->loadAll(Status::class, "{$this}/project_statuses"); |
168 | 168 | } |
169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param array $query |
173 | 173 | * @return Task[] |
174 | 174 | */ |
175 | - public function getTasks (array $query = []) { |
|
175 | + public function getTasks(array $query = []) { |
|
176 | 176 | $query['project'] = $this->getGid(); |
177 | 177 | return $this->loadAll(Task::class, "tasks", $query); |
178 | 178 | } |
@@ -181,25 +181,25 @@ discard block |
||
181 | 181 | * @depends after-create |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - public function getUrl (): string { |
|
184 | + public function getUrl(): string { |
|
185 | 185 | return "https://app.asana.com/0/{$this->getGid()}"; |
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
189 | 189 | * @return ProjectWebhook[] |
190 | 190 | */ |
191 | - public function getWebhooks () { |
|
191 | + public function getWebhooks() { |
|
192 | 192 | return $this->loadAll(ProjectWebhook::class, 'webhooks', [ |
193 | 193 | 'workspace' => $this->getWorkspace()->getGid(), |
194 | 194 | 'resource' => $this->getGid() |
195 | 195 | ]); |
196 | 196 | } |
197 | 197 | |
198 | - public function isBoard (): bool { |
|
198 | + public function isBoard(): bool { |
|
199 | 199 | return $this->getLayout() === self::LAYOUT_BOARD; |
200 | 200 | } |
201 | 201 | |
202 | - public function isList (): bool { |
|
202 | + public function isList(): bool { |
|
203 | 203 | return $this->getLayout() === self::LAYOUT_LIST; |
204 | 204 | } |
205 | 205 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @depends after-create |
208 | 208 | * @return Section |
209 | 209 | */ |
210 | - public function newSection () { |
|
210 | + public function newSection() { |
|
211 | 211 | return $this->factory(Section::class, ['projects' => [$this]]); |
212 | 212 | } |
213 | 213 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @depends after-create |
216 | 216 | * @return Status |
217 | 217 | */ |
218 | - public function newStatus () { |
|
218 | + public function newStatus() { |
|
219 | 219 | return $this->factory(Status::class); |
220 | 220 | } |
221 | 221 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @depends after-create |
226 | 226 | * @return Task |
227 | 227 | */ |
228 | - public function newTask () { |
|
228 | + public function newTask() { |
|
229 | 229 | return $this->getSections()[0]->newTask(); |
230 | 230 | } |
231 | 231 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @param User $user |
235 | 235 | * @return $this |
236 | 236 | */ |
237 | - public function removeMember (User $user) { |
|
237 | + public function removeMember(User $user) { |
|
238 | 238 | return $this->removeMembers([$user]); |
239 | 239 | } |
240 | 240 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @param User[] $users |
244 | 244 | * @return $this |
245 | 245 | */ |
246 | - public function removeMembers (array $users) { |
|
246 | + public function removeMembers(array $users) { |
|
247 | 247 | $this->api->post("{$this}/removeMembers", ['members' => array_column($users, 'gid')]); |
248 | 248 | $this->_remove('members', $users); |
249 | 249 | return $this; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @param null|Team $team |
255 | 255 | * @return $this |
256 | 256 | */ |
257 | - public function setTeam (?Team $team) { |
|
257 | + public function setTeam(?Team $team) { |
|
258 | 258 | assert(!$this->hasGid()); |
259 | 259 | if ($team and !$this->hasWorkspace()) { |
260 | 260 | $this->setWorkspace($team->getOrganization()); |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | 'memberships' => 'memberships.(project|section)' |
96 | 96 | ]; |
97 | 97 | |
98 | - final public function __toString (): string { |
|
98 | + final public function __toString(): string { |
|
99 | 99 | return "tasks/{$this->getGid()}"; |
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Clears the diffs for `custom_fields` and `external` sub-objects after saving. |
104 | 104 | */ |
105 | - protected function _clearSubDiffs (): void { |
|
105 | + protected function _clearSubDiffs(): void { |
|
106 | 106 | // use isset() to avoid has() fetch. |
107 | 107 | if (isset($this->data['custom_fields'])) { |
108 | 108 | $this->getCustomFields()->diff = []; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - final protected function _getDir (): string { |
|
115 | + final protected function _getDir(): string { |
|
116 | 116 | return 'tasks'; |
117 | 117 | } |
118 | 118 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param string $file |
124 | 124 | * @return Attachment |
125 | 125 | */ |
126 | - public function addAttachment (string $file) { |
|
126 | + public function addAttachment(string $file) { |
|
127 | 127 | /** @var Attachment $attachment */ |
128 | 128 | $attachment = $this->factory(Attachment::class, ['parent' => $this]); |
129 | 129 | return $attachment->upload($file); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param string $text |
136 | 136 | * @return Story |
137 | 137 | */ |
138 | - public function addComment (string $text) { |
|
138 | + public function addComment(string $text) { |
|
139 | 139 | return $this->newComment()->setText($text)->create(); |
140 | 140 | } |
141 | 141 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param Task[] $tasks |
147 | 147 | * @return $this |
148 | 148 | */ |
149 | - public function addDependencies (array $tasks) { |
|
149 | + public function addDependencies(array $tasks) { |
|
150 | 150 | $this->api->post("{$this}/addDependencies", ['dependents' => array_column($tasks, 'gid')]); |
151 | 151 | return $this; |
152 | 152 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @param Task $task |
159 | 159 | * @return $this |
160 | 160 | */ |
161 | - public function addDependency (Task $task) { |
|
161 | + public function addDependency(Task $task) { |
|
162 | 162 | return $this->addDependencies([$task]); |
163 | 163 | } |
164 | 164 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param Task $task |
170 | 170 | * @return $this |
171 | 171 | */ |
172 | - public function addDependent (Task $task) { |
|
172 | + public function addDependent(Task $task) { |
|
173 | 173 | return $this->addDependents([$task]); |
174 | 174 | } |
175 | 175 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param Task[] $tasks |
181 | 181 | * @return $this |
182 | 182 | */ |
183 | - public function addDependents (array $tasks) { |
|
183 | + public function addDependents(array $tasks) { |
|
184 | 184 | $this->api->post("{$this}/addDependents", ['dependents' => array_column($tasks, 'gid')]); |
185 | 185 | return $this; |
186 | 186 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param User $user |
192 | 192 | * @return $this |
193 | 193 | */ |
194 | - public function addFollower (User $user) { |
|
194 | + public function addFollower(User $user) { |
|
195 | 195 | return $this->addFollowers([$user]); |
196 | 196 | } |
197 | 197 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @param User[] $users |
202 | 202 | * @return $this |
203 | 203 | */ |
204 | - public function addFollowers (array $users) { |
|
204 | + public function addFollowers(array $users) { |
|
205 | 205 | if ($this->hasGid()) { |
206 | 206 | $this->api->post("{$this}/addFollowers", ['followers' => array_column($users, 'gid')]); |
207 | 207 | $this->_merge('followers', $users); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param Tag $tag |
219 | 219 | * @return $this |
220 | 220 | */ |
221 | - public function addTag (Tag $tag) { |
|
221 | + public function addTag(Tag $tag) { |
|
222 | 222 | if ($this->hasGid()) { |
223 | 223 | $this->api->post("{$this}/addTag", ['tag' => $tag->getGid()]); |
224 | 224 | $this->_merge('tags', [$tag]); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param Project|Section $target |
236 | 236 | * @return $this |
237 | 237 | */ |
238 | - public function addToProject ($target) { |
|
238 | + public function addToProject($target) { |
|
239 | 239 | if ($target instanceof Project) { |
240 | 240 | $project = $target; |
241 | 241 | $section = null; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param string $target |
277 | 277 | * @return TaskWebhook |
278 | 278 | */ |
279 | - public function addWebhook (string $target) { |
|
279 | + public function addWebhook(string $target) { |
|
280 | 280 | /** @var TaskWebhook $webhook */ |
281 | 281 | $webhook = $this->factory(TaskWebhook::class); |
282 | 282 | return $webhook->create($this, $target); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | /** |
286 | 286 | * @return $this |
287 | 287 | */ |
288 | - public function create () { |
|
288 | + public function create() { |
|
289 | 289 | $this->_create(); |
290 | 290 | $this->_clearSubDiffs(); |
291 | 291 | return $this; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param string[] $include |
302 | 302 | * @return Job |
303 | 303 | */ |
304 | - public function duplicate (string $name, array $include) { |
|
304 | + public function duplicate(string $name, array $include) { |
|
305 | 305 | $remote = $this->api->post("{$this}/duplicate", [ |
306 | 306 | 'name' => $name, |
307 | 307 | 'include' => array_values($include) |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @depends after-create |
316 | 316 | * @return Attachment[] |
317 | 317 | */ |
318 | - public function getAttachments () { |
|
318 | + public function getAttachments() { |
|
319 | 319 | return $this->loadAll(Attachment::class, "{$this}/attachments"); |
320 | 320 | } |
321 | 321 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | * @depends after-create |
326 | 326 | * @return Story[] |
327 | 327 | */ |
328 | - public function getComments () { |
|
328 | + public function getComments() { |
|
329 | 329 | return array_values(array_filter($this->getStories(), function(Story $story) { |
330 | 330 | return $story->isComment(); |
331 | 331 | })); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @depends after-create |
338 | 338 | * @return Task[] |
339 | 339 | */ |
340 | - public function getDependencies () { |
|
340 | + public function getDependencies() { |
|
341 | 341 | return $this->loadAll(self::class, "{$this}/dependencies"); |
342 | 342 | } |
343 | 343 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * @depends after-create |
348 | 348 | * @return Task[] |
349 | 349 | */ |
350 | - public function getDependents () { |
|
350 | + public function getDependents() { |
|
351 | 351 | return $this->loadAll(self::class, "{$this}/dependents"); |
352 | 352 | } |
353 | 353 | |
@@ -358,21 +358,21 @@ discard block |
||
358 | 358 | * @param null|string $token |
359 | 359 | * @return TaskEvent[]|StoryEvent[] |
360 | 360 | */ |
361 | - public function getEvents (&$token) { |
|
361 | + public function getEvents(&$token) { |
|
362 | 362 | return $this->api->sync($this, $token); |
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
366 | 366 | * @return External |
367 | 367 | */ |
368 | - public function getExternal () { |
|
368 | + public function getExternal() { |
|
369 | 369 | return $this->_get('external') ?? $this->data['external'] = $this->factory(static::$map['external']); |
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
373 | 373 | * @return Project[] |
374 | 374 | */ |
375 | - public function getProjects () { |
|
375 | + public function getProjects() { |
|
376 | 376 | return array_map(function(Membership $membership) { |
377 | 377 | return $membership->getProject(); |
378 | 378 | }, $this->getMemberships()); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @depends after-create |
385 | 385 | * @return Story[] |
386 | 386 | */ |
387 | - public function getStories () { |
|
387 | + public function getStories() { |
|
388 | 388 | return $this->loadAll(Story::class, "{$this}/stories"); |
389 | 389 | } |
390 | 390 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * @depends after-create |
395 | 395 | * @return Task[] |
396 | 396 | */ |
397 | - public function getSubTasks () { |
|
397 | + public function getSubTasks() { |
|
398 | 398 | return $this->loadAll(self::class, "{$this}/subtasks"); |
399 | 399 | } |
400 | 400 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @depends after-create |
405 | 405 | * @return string |
406 | 406 | */ |
407 | - public function getUrl (): string { |
|
407 | + public function getUrl(): string { |
|
408 | 408 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
409 | 409 | } |
410 | 410 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * @depends after-create |
415 | 415 | * @return TaskWebhook[] |
416 | 416 | */ |
417 | - public function getWebhooks () { |
|
417 | + public function getWebhooks() { |
|
418 | 418 | return $this->loadAll(TaskWebhook::class, 'webhooks', [ |
419 | 419 | 'workspace' => $this->getWorkspace()->getGid(), |
420 | 420 | 'resource' => $this->getGid() |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | /** |
425 | 425 | * @return bool |
426 | 426 | */ |
427 | - public function isRenderedAsSeparator (): bool { |
|
427 | + public function isRenderedAsSeparator(): bool { |
|
428 | 428 | return $this->_is('is_rendered_as_separator'); |
429 | 429 | } |
430 | 430 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * @depends after-create |
435 | 435 | * @return Story |
436 | 436 | */ |
437 | - public function newComment () { |
|
437 | + public function newComment() { |
|
438 | 438 | /** @var Story $comment */ |
439 | 439 | $comment = $this->factory(Story::class, [ |
440 | 440 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * @depends after-create |
449 | 449 | * @return Task |
450 | 450 | */ |
451 | - public function newSubTask () { |
|
451 | + public function newSubTask() { |
|
452 | 452 | /** @var Task $sub */ |
453 | 453 | $sub = $this->factory(self::class); |
454 | 454 | return $sub->setParent($this); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | * @param Task[] $tasks |
462 | 462 | * @return $this |
463 | 463 | */ |
464 | - public function removeDependencies (array $tasks) { |
|
464 | + public function removeDependencies(array $tasks) { |
|
465 | 465 | $this->api->post("{$this}/removeDependencies", ['dependencies' => array_column($tasks, 'gid')]); |
466 | 466 | return $this; |
467 | 467 | } |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | * @param Task $task |
474 | 474 | * @return $this |
475 | 475 | */ |
476 | - public function removeDependency (Task $task) { |
|
476 | + public function removeDependency(Task $task) { |
|
477 | 477 | return $this->removeDependencies([$task]); |
478 | 478 | } |
479 | 479 | |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | * @param Task $task |
485 | 485 | * @return $this |
486 | 486 | */ |
487 | - public function removeDependent (Task $task) { |
|
487 | + public function removeDependent(Task $task) { |
|
488 | 488 | return $this->removeDependents([$task]); |
489 | 489 | } |
490 | 490 | |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * @param Task[] $tasks |
496 | 496 | * @return $this |
497 | 497 | */ |
498 | - public function removeDependents (array $tasks) { |
|
498 | + public function removeDependents(array $tasks) { |
|
499 | 499 | $this->api->post("{$this}/removeDependents", ['dependents' => array_column($tasks, 'gid')]); |
500 | 500 | return $this; |
501 | 501 | } |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @param User $user |
507 | 507 | * @return $this |
508 | 508 | */ |
509 | - public function removeFollower (User $user) { |
|
509 | + public function removeFollower(User $user) { |
|
510 | 510 | return $this->removeFollowers([$user]); |
511 | 511 | } |
512 | 512 | |
@@ -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 | if ($this->hasGid()) { |
521 | 521 | $this->api->post("{$this}/removeFollowers", ['followers' => array_column($users, 'gid')]); |
522 | 522 | } |
@@ -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 | $gid = $project->getGid(); |
535 | 535 | if ($this->hasGid()) { |
536 | 536 | $this->api->post("{$this}/removeProject", ['project' => $gid]); |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * @param Tag $tag |
550 | 550 | * @return $this |
551 | 551 | */ |
552 | - public function removeTag (Tag $tag) { |
|
552 | + public function removeTag(Tag $tag) { |
|
553 | 553 | if ($this->hasGid()) { |
554 | 554 | $this->api->post("{$this}/removeTag", ['tag' => $tag->getGid()]); |
555 | 555 | } |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @param null|Task $parent |
564 | 564 | * @return $this |
565 | 565 | */ |
566 | - public function setParent (?self $parent) { |
|
566 | + public function setParent(?self $parent) { |
|
567 | 567 | if ($this->hasGid()) { |
568 | 568 | $this->api->post("{$this}/setParent", ['parent' => $parent ? $parent->getGid() : null]); |
569 | 569 | $this->data['parent'] = $parent; |
@@ -578,14 +578,14 @@ discard block |
||
578 | 578 | * @param bool $flag |
579 | 579 | * @return $this |
580 | 580 | */ |
581 | - public function setRenderedAsSeparator (bool $flag) { |
|
581 | + public function setRenderedAsSeparator(bool $flag) { |
|
582 | 582 | return $this->_set('is_rendered_as_separator', $flag); |
583 | 583 | } |
584 | 584 | |
585 | 585 | /** |
586 | 586 | * @return $this |
587 | 587 | */ |
588 | - public function update () { |
|
588 | + public function update() { |
|
589 | 589 | $this->_update(); |
590 | 590 | $this->_clearSubDiffs(); |
591 | 591 | return $this; |
@@ -205,8 +205,7 @@ discard block |
||
205 | 205 | if ($this->hasGid()) { |
206 | 206 | $this->api->post("{$this}/addFollowers", ['followers' => array_column($users, 'gid')]); |
207 | 207 | $this->_merge('followers', $users); |
208 | - } |
|
209 | - else { |
|
208 | + } else { |
|
210 | 209 | $this->_merge('followers', $users, true); |
211 | 210 | } |
212 | 211 | return $this; |
@@ -222,8 +221,7 @@ discard block |
||
222 | 221 | if ($this->hasGid()) { |
223 | 222 | $this->api->post("{$this}/addTag", ['tag' => $tag->getGid()]); |
224 | 223 | $this->_merge('tags', [$tag]); |
225 | - } |
|
226 | - else { |
|
224 | + } else { |
|
227 | 225 | $this->_merge('tags', [$tag], true); |
228 | 226 | } |
229 | 227 | return $this; |
@@ -239,8 +237,7 @@ discard block |
||
239 | 237 | if ($target instanceof Project) { |
240 | 238 | $project = $target; |
241 | 239 | $section = null; |
242 | - } |
|
243 | - else { |
|
240 | + } else { |
|
244 | 241 | $project = $target->getProject(); |
245 | 242 | $section = $target; |
246 | 243 | } |
@@ -255,8 +252,7 @@ discard block |
||
255 | 252 | 'section' => $section |
256 | 253 | ]) |
257 | 254 | ]); |
258 | - } |
|
259 | - else { |
|
255 | + } else { |
|
260 | 256 | if (!$this->hasWorkspace()) { |
261 | 257 | $this->setWorkspace($project->getWorkspace()); |
262 | 258 | } |
@@ -567,8 +563,7 @@ discard block |
||
567 | 563 | if ($this->hasGid()) { |
568 | 564 | $this->api->post("{$this}/setParent", ['parent' => $parent ? $parent->getGid() : null]); |
569 | 565 | $this->data['parent'] = $parent; |
570 | - } |
|
571 | - else { |
|
566 | + } else { |
|
572 | 567 | $this->_set('parent', $parent); |
573 | 568 | } |
574 | 569 | return $this; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @return string |
18 | 18 | */ |
19 | - abstract public function __toString (): string; |
|
19 | + abstract public function __toString(): string; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Maps lazy-loaded / reloadable mapped {@see Data} to their proper expanded field expression. |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Shortcut to update the cache. |
32 | 32 | */ |
33 | - protected function _cache (): void { |
|
33 | + protected function _cache(): void { |
|
34 | 34 | $this->api->getCache()->add($this); |
35 | 35 | } |
36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param string $key |
41 | 41 | * @return mixed |
42 | 42 | */ |
43 | - protected function _get (string $key) { |
|
43 | + protected function _get(string $key) { |
|
44 | 44 | if (!array_key_exists($key, $this->data) and isset($this->data['gid'])) { // can't use hasGid(), inf. loop |
45 | 45 | $this->reload($key); |
46 | 46 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param bool $force |
56 | 56 | * @return $this |
57 | 57 | */ |
58 | - protected function _merge (string $key, array $entities, $force = false) { |
|
58 | + protected function _merge(string $key, array $entities, $force = false) { |
|
59 | 59 | if ($force or isset($this->data[$key])) { |
60 | 60 | foreach ($entities as $entity) { |
61 | 61 | $this->data[$key][] = $entity; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param AbstractEntity[] $entities |
79 | 79 | * @return $this |
80 | 80 | */ |
81 | - protected function _remove (string $key, array $entities) { |
|
81 | + protected function _remove(string $key, array $entities) { |
|
82 | 82 | if (isset($this->data[$key])) { |
83 | 83 | $this->data[$key] = array_values(array_diff($this->data[$key], $entities)); |
84 | 84 | $this->_cache(); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return string[] |
93 | 93 | */ |
94 | - public function getCacheKeys () { |
|
94 | + public function getCacheKeys() { |
|
95 | 95 | return [$this->getGid(), (string)$this]; |
96 | 96 | } |
97 | 97 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param string $key |
102 | 102 | * @return $this |
103 | 103 | */ |
104 | - public function reload (string $key = null) { |
|
104 | + public function reload(string $key = null) { |
|
105 | 105 | if (isset($key)) { |
106 | 106 | $value = $this->api->get($this, [], ['fields' => static::$optFields[$key] ?? $key])[$key] ?? null; |
107 | 107 | $this->_setMapped($key, $value); |
@@ -63,8 +63,7 @@ discard block |
||
63 | 63 | $this->data[$key] = array_values(array_unique($this->data[$key])); |
64 | 64 | if ($force) { |
65 | 65 | $this->diff[$key] = true; |
66 | - } |
|
67 | - else { |
|
66 | + } else { |
|
68 | 67 | $this->_cache(); |
69 | 68 | } |
70 | 69 | } |
@@ -105,8 +104,7 @@ discard block |
||
105 | 104 | if (isset($key)) { |
106 | 105 | $value = $this->api->get($this, [], ['fields' => static::$optFields[$key] ?? $key])[$key] ?? null; |
107 | 106 | $this->_setMapped($key, $value); |
108 | - } |
|
109 | - else { |
|
107 | + } else { |
|
110 | 108 | $this->_setData($this->api->get($this, [], ['expand' => 'this'])); |
111 | 109 | } |
112 | 110 | $this->_cache(); |