@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - abstract public function __toString (): string; |
|
24 | + abstract public function __toString(): string; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Maps lazy-loaded / reloadable mapped {@see Data} to their proper expanded field expression. |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param AbstractEntity $entity |
42 | 42 | * @internal |
43 | 43 | */ |
44 | - public function __set (string $from, self $entity) { |
|
44 | + public function __set(string $from, self $entity) { |
|
45 | 45 | if ($from === Cache::class and $entity !== $this) { |
46 | 46 | foreach ($entity->data as $field => $value) { |
47 | 47 | if (!isset($this->diff[$field])) { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return $this |
60 | 60 | * @internal |
61 | 61 | */ |
62 | - protected function _addWithPost (string $addPath, array $data, string $field, array $diff) { |
|
62 | + protected function _addWithPost(string $addPath, array $data, string $field, array $diff) { |
|
63 | 63 | if ($this->hasGid()) { |
64 | 64 | return $this->_setWithPost($addPath, $data, $field); |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @internal |
73 | 73 | */ |
74 | - protected function _cache (): void { |
|
74 | + protected function _cache(): void { |
|
75 | 75 | $this->api->getCache()->add($this); |
76 | 76 | } |
77 | 77 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @internal |
82 | 82 | */ |
83 | - protected function _delete (): void { |
|
83 | + protected function _delete(): void { |
|
84 | 84 | $this->api->delete($this); |
85 | 85 | $this->api->getCache()->remove($this); |
86 | 86 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param string $field |
92 | 92 | * @return mixed |
93 | 93 | */ |
94 | - protected function _get (string $field) { |
|
94 | + protected function _get(string $field) { |
|
95 | 95 | if (!array_key_exists($field, $this->data) and isset($this->data['gid'])) { |
96 | 96 | $this->reload($field); |
97 | 97 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @return $this |
107 | 107 | * @internal |
108 | 108 | */ |
109 | - protected function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
|
109 | + protected function _removeWithPost(string $rmPath, array $data, string $field, $diff) { |
|
110 | 110 | if ($this->hasGid()) { |
111 | 111 | return $this->_setWithPost($rmPath, $data, $field); |
112 | 112 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @return $this |
124 | 124 | * @internal |
125 | 125 | */ |
126 | - protected function _save (string $dir = null) { |
|
126 | + protected function _save(string $dir = null) { |
|
127 | 127 | if (isset($dir)) { |
128 | 128 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
129 | 129 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return $this |
150 | 150 | * @internal |
151 | 151 | */ |
152 | - protected function _setWithPost (string $path, array $data, string $field, $value = null) { |
|
152 | + protected function _setWithPost(string $path, array $data, string $field, $value = null) { |
|
153 | 153 | if ($this->hasGid()) { |
154 | 154 | /** @var array $remote */ |
155 | 155 | $remote = $this->api->post($path, $data, ['fields' => static::$optFields[$field] ?? $field]); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return string[] |
169 | 169 | */ |
170 | - public function getCacheKeys () { |
|
170 | + public function getCacheKeys() { |
|
171 | 171 | return [$this->getGid(), (string)$this]; |
172 | 172 | } |
173 | 173 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param string $field |
179 | 179 | * @return $this |
180 | 180 | */ |
181 | - public function reload (string $field = null) { |
|
181 | + public function reload(string $field = null) { |
|
182 | 182 | if (!$this->hasGid()) { |
183 | 183 | throw new LogicException(static::class . " has no GID, it can't be reloaded."); |
184 | 184 | } |
@@ -109,8 +109,7 @@ discard block |
||
109 | 109 | protected function _removeWithPost (string $rmPath, array $data, string $field, $diff) { |
110 | 110 | if ($this->hasGid()) { |
111 | 111 | return $this->_setWithPost($rmPath, $data, $field); |
112 | - } |
|
113 | - elseif (is_array($diff)) { |
|
112 | + } elseif (is_array($diff)) { |
|
114 | 113 | return $this->_set($field, array_values(array_diff($this->data[$field] ?? [], $diff))); |
115 | 114 | } |
116 | 115 | return $this->_set($field, array_values(array_filter($this->data[$field] ?? [], $diff))); |
@@ -126,11 +125,9 @@ discard block |
||
126 | 125 | protected function _save (string $dir = null) { |
127 | 126 | if (isset($dir)) { |
128 | 127 | $remote = $this->api->post($dir, $this->getDiff(), ['expand' => 'this']); |
129 | - } |
|
130 | - elseif ($this->isDiff()) { |
|
128 | + } elseif ($this->isDiff()) { |
|
131 | 129 | $remote = $this->api->put($this, $this->getDiff(), ['expand' => 'this']); |
132 | - } |
|
133 | - else { |
|
130 | + } else { |
|
134 | 131 | return $this; |
135 | 132 | } |
136 | 133 | /** @var array $remote */ |
@@ -186,11 +183,9 @@ discard block |
||
186 | 183 | $optField = static::$optFields[$field] ?? $field; |
187 | 184 | $value = $this->api->get($this, [], ['fields' => $optField])[$field] ?? null; |
188 | 185 | $this->_setMapped($field, $value); |
189 | - } |
|
190 | - elseif ($remote = $this->api->get($this, [], ['expand' => 'this'])) { |
|
186 | + } elseif ($remote = $this->api->get($this, [], ['expand' => 'this'])) { |
|
191 | 187 | $this->_setData($remote); |
192 | - } |
|
193 | - else { // deleted upstream. |
|
188 | + } else { // deleted upstream. |
|
194 | 189 | $this->api->getCache()->remove($this); |
195 | 190 | throw new RuntimeException("{$this} was deleted upstream."); |
196 | 191 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | const TYPE = 'workspace'; |
29 | 29 | |
30 | - final public function __toString (): string { |
|
30 | + final public function __toString(): string { |
|
31 | 31 | return "workspaces/{$this->getGid()}"; |
32 | 32 | } |
33 | 33 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return OrganizationExport |
38 | 38 | */ |
39 | - public function export () { |
|
39 | + public function export() { |
|
40 | 40 | /** @var OrganizationExport $export */ |
41 | 41 | $export = $this->factory(OrganizationExport::class); |
42 | 42 | return $export->create($this); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param int $limit 1-100 |
58 | 58 | * @return array|AbstractEntity[] |
59 | 59 | */ |
60 | - protected function find (string $class, string $resourceType, string $text, int $limit = 20) { |
|
60 | + protected function find(string $class, string $resourceType, string $text, int $limit = 20) { |
|
61 | 61 | return $this->loadAll($class, "{$this}/typeahead", [ |
62 | 62 | 'resource_type' => $resourceType, |
63 | 63 | 'query' => $text, |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param int $limit 1-100 |
73 | 73 | * @return CustomField[] |
74 | 74 | */ |
75 | - public function findCustomFields (string $text, int $limit = 20) { |
|
75 | + public function findCustomFields(string $text, int $limit = 20) { |
|
76 | 76 | return $this->find(CustomField::class, CustomField::TYPE, $text, $limit); |
77 | 77 | } |
78 | 78 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param int $limit 1-100 |
84 | 84 | * @return Portfolio[] |
85 | 85 | */ |
86 | - public function findPortfolios (string $text, int $limit = 20) { |
|
86 | + public function findPortfolios(string $text, int $limit = 20) { |
|
87 | 87 | return $this->find(Portfolio::class, Portfolio::TYPE, $text, $limit); |
88 | 88 | } |
89 | 89 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param int $limit 1-100 |
95 | 95 | * @return Project[] |
96 | 96 | */ |
97 | - public function findProjects (string $text, int $limit = 20) { |
|
97 | + public function findProjects(string $text, int $limit = 20) { |
|
98 | 98 | return $this->find(Project::class, Project::TYPE, $text, $limit); |
99 | 99 | } |
100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param int $limit 1-100 |
106 | 106 | * @return Tag[] |
107 | 107 | */ |
108 | - public function findTags (string $text, int $limit = 20) { |
|
108 | + public function findTags(string $text, int $limit = 20) { |
|
109 | 109 | return $this->find(Tag::class, Tag::TYPE, $text, $limit); |
110 | 110 | } |
111 | 111 | |
@@ -116,14 +116,14 @@ discard block |
||
116 | 116 | * @param int $limit 1-100 |
117 | 117 | * @return Task[] |
118 | 118 | */ |
119 | - public function findTasks (string $text, int $limit = 20) { |
|
119 | + public function findTasks(string $text, int $limit = 20) { |
|
120 | 120 | return $this->find(Task::class, Task::TYPE, $text, $limit); |
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return CustomField[] |
125 | 125 | */ |
126 | - public function getCustomFields () { |
|
126 | + public function getCustomFields() { |
|
127 | 127 | return $this->loadAll(CustomField::class, "{$this}/custom_fields"); |
128 | 128 | } |
129 | 129 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return Portfolio[] |
136 | 136 | */ |
137 | - public function getPortfolios () { |
|
137 | + public function getPortfolios() { |
|
138 | 138 | return $this->loadAll(Portfolio::class, "portfolios", [ |
139 | 139 | 'workspace' => $this->getGid(), |
140 | 140 | 'owner' => $this->api->getMe()->getGid() // the only allowed value, but still required. |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param array $filter |
150 | 150 | * @return Project[] |
151 | 151 | */ |
152 | - public function getProjects (array $filter = ['archived' => false]) { |
|
152 | + public function getProjects(array $filter = ['archived' => false]) { |
|
153 | 153 | $filter['workspace'] = $this->getGid(); |
154 | 154 | return $this->loadAll(Project::class, 'projects', $filter); |
155 | 155 | } |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | /** |
158 | 158 | * @return Tag[] |
159 | 159 | */ |
160 | - public function getTags () { |
|
160 | + public function getTags() { |
|
161 | 161 | return $this->loadAll(Tag::class, 'tags', ['workspace' => $this->getGid()]); |
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * @return Team[] |
166 | 166 | */ |
167 | - public function getTeams () { |
|
167 | + public function getTeams() { |
|
168 | 168 | return $this->loadAll(Team::class, "organizations/{$this->getGid()}/teams"); |
169 | 169 | } |
170 | 170 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param string $email |
173 | 173 | * @return null|User |
174 | 174 | */ |
175 | - public function getUserByEmail (string $email) { |
|
175 | + public function getUserByEmail(string $email) { |
|
176 | 176 | return $this->api->getCache()->get("users/{$email}", $this, function() use ($email) { |
177 | 177 | foreach ($this->getUsers() as $user) { |
178 | 178 | if ($user->getEmail() === $email) { |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | /** |
187 | 187 | * @return User[] |
188 | 188 | */ |
189 | - public function getUsers () { |
|
189 | + public function getUsers() { |
|
190 | 190 | return $this->loadAll(User::class, "{$this}/users"); |
191 | 191 | } |
192 | 192 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return ProjectWebhook[]|TaskWebhook[] |
197 | 197 | */ |
198 | - public function getWebhooks () { |
|
198 | + public function getWebhooks() { |
|
199 | 199 | /** @var array $all */ |
200 | 200 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
201 | 201 | return array_map(function(array $each) { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | /** |
213 | 213 | * @return bool |
214 | 214 | */ |
215 | - public function isOrganization (): bool { |
|
215 | + public function isOrganization(): bool { |
|
216 | 216 | return $this->_is('is_organization'); |
217 | 217 | } |
218 | 218 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return CustomField |
223 | 223 | */ |
224 | - public function newCustomField () { |
|
224 | + public function newCustomField() { |
|
225 | 225 | /** @var CustomField $field */ |
226 | 226 | $field = $this->factory(CustomField::class); |
227 | 227 | return $field->setWorkspace($this); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return Portfolio |
234 | 234 | */ |
235 | - public function newPortfolio () { |
|
235 | + public function newPortfolio() { |
|
236 | 236 | /** @var Portfolio $portfolio */ |
237 | 237 | $portfolio = $this->factory(Portfolio::class); |
238 | 238 | return $portfolio->setWorkspace($this); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @return Project |
245 | 245 | */ |
246 | - public function newProject () { |
|
246 | + public function newProject() { |
|
247 | 247 | /** @var Project $project */ |
248 | 248 | $project = $this->factory(Project::class); |
249 | 249 | return $project->setWorkspace($this); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return Tag |
256 | 256 | */ |
257 | - public function newTag () { |
|
257 | + public function newTag() { |
|
258 | 258 | /** @var Tag $tag */ |
259 | 259 | $tag = $this->factory(Tag::class); |
260 | 260 | return $tag->setWorkspace($this); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return Task |
267 | 267 | */ |
268 | - public function newTask () { |
|
268 | + public function newTask() { |
|
269 | 269 | /** @var Task $task */ |
270 | 270 | $task = $this->factory(Task::class); |
271 | 271 | return $task->setWorkspace($this); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @param callable $filter `fn( CustomField $field ): bool` |
276 | 276 | * @return CustomField[] |
277 | 277 | */ |
278 | - public function selectCustomFields (callable $filter) { |
|
278 | + public function selectCustomFields(callable $filter) { |
|
279 | 279 | return $this->_select($this->getCustomFields(), $filter); |
280 | 280 | } |
281 | 281 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param callable $filter `fn( Portfolio $portfolio ): bool` |
284 | 284 | * @return Portfolio[] |
285 | 285 | */ |
286 | - public function selectPortfolios (callable $filter) { |
|
286 | + public function selectPortfolios(callable $filter) { |
|
287 | 287 | return $this->_select($this->getPortfolios(), $filter); |
288 | 288 | } |
289 | 289 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @param callable $filter `fn( Project $project ): bool` |
292 | 292 | * @return Project[] |
293 | 293 | */ |
294 | - public function selectProjects (callable $filter) { |
|
294 | + public function selectProjects(callable $filter) { |
|
295 | 295 | return $this->_select($this->getProjects([]), $filter); |
296 | 296 | } |
297 | 297 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param callable $filter `fn( Tag $tag ): bool` |
300 | 300 | * @return Tag[] |
301 | 301 | */ |
302 | - public function selectTags (callable $filter) { |
|
302 | + public function selectTags(callable $filter) { |
|
303 | 303 | return $this->_select($this->getTags(), $filter); |
304 | 304 | } |
305 | 305 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @param callable $filter `fn( Team $team ): bool` |
308 | 308 | * @return Team[] |
309 | 309 | */ |
310 | - public function selectTeams (callable $filter) { |
|
310 | + public function selectTeams(callable $filter) { |
|
311 | 311 | return $this->_select($this->getTeams(), $filter); |
312 | 312 | } |
313 | 313 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @param callable $filter |
316 | 316 | * @return User[] |
317 | 317 | */ |
318 | - public function selectUsers (callable $filter) { |
|
318 | + public function selectUsers(callable $filter) { |
|
319 | 319 | return $this->_select($this->getUsers(), $filter); |
320 | 320 | } |
321 | 321 | } |
322 | 322 | \ No newline at end of file |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | 'workspace' => Workspace::class |
71 | 71 | ]; |
72 | 72 | |
73 | - final public function __toString (): string { |
|
73 | + final public function __toString(): string { |
|
74 | 74 | return "projects/{$this->getGid()}"; |
75 | 75 | } |
76 | 76 | |
77 | - final protected function _getDir (): string { |
|
77 | + final protected function _getDir(): string { |
|
78 | 78 | return 'projects'; |
79 | 79 | } |
80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param User $user |
84 | 84 | * @return $this |
85 | 85 | */ |
86 | - public function addMember (User $user) { |
|
86 | + public function addMember(User $user) { |
|
87 | 87 | return $this->addMembers([$user]); |
88 | 88 | } |
89 | 89 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param User[] $users |
93 | 93 | * @return $this |
94 | 94 | */ |
95 | - public function addMembers (array $users) { |
|
95 | + public function addMembers(array $users) { |
|
96 | 96 | return $this->_addWithPost("{$this}/addMembers", [ |
97 | 97 | 'members' => array_column($users, 'gid') |
98 | 98 | ], 'members', $users); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param string $target |
104 | 104 | * @return ProjectWebhook |
105 | 105 | */ |
106 | - public function addWebhook (string $target) { |
|
106 | + public function addWebhook(string $target) { |
|
107 | 107 | /** @var ProjectWebhook $webhook */ |
108 | 108 | $webhook = $this->factory(ProjectWebhook::class); |
109 | 109 | return $webhook->create($this, $target); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param array $schedule |
129 | 129 | * @return Job |
130 | 130 | */ |
131 | - public function duplicate (string $name, array $include, Team $team = null, array $schedule = []) { |
|
131 | + public function duplicate(string $name, array $include, Team $team = null, array $schedule = []) { |
|
132 | 132 | $data = ['name' => $name]; |
133 | 133 | if ($team) { |
134 | 134 | $data['team'] = $team->getGid(); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @depends after-create |
148 | 148 | * @return Section |
149 | 149 | */ |
150 | - public function getDefaultSection () { |
|
150 | + public function getDefaultSection() { |
|
151 | 151 | return $this->loadAll(Section::class, "{$this}/sections", ['limit' => 1])[0]; |
152 | 152 | } |
153 | 153 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @param null|string $token |
159 | 159 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
160 | 160 | */ |
161 | - public function getEvents (&$token) { |
|
161 | + public function getEvents(&$token) { |
|
162 | 162 | return $this->api->sync($this, $token); |
163 | 163 | } |
164 | 164 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @depends after-create |
167 | 167 | * @return Section[] |
168 | 168 | */ |
169 | - public function getSections () { |
|
169 | + public function getSections() { |
|
170 | 170 | return $this->loadAll(Section::class, "{$this}/sections"); |
171 | 171 | } |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @depends after-create |
175 | 175 | * @return Status[] |
176 | 176 | */ |
177 | - public function getStatuses () { |
|
177 | + public function getStatuses() { |
|
178 | 178 | return $this->loadAll(Status::class, "{$this}/project_statuses"); |
179 | 179 | } |
180 | 180 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param array $filter |
188 | 188 | * @return Task[] |
189 | 189 | */ |
190 | - public function getTasks (array $filter = []) { |
|
190 | + public function getTasks(array $filter = []) { |
|
191 | 191 | $filter['project'] = $this->getGid(); |
192 | 192 | return $this->loadAll(Task::class, "tasks", $filter); |
193 | 193 | } |
@@ -196,25 +196,25 @@ discard block |
||
196 | 196 | * @depends after-create |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function getUrl (): string { |
|
199 | + public function getUrl(): string { |
|
200 | 200 | return "https://app.asana.com/0/{$this->getGid()}"; |
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
204 | 204 | * @return ProjectWebhook[] |
205 | 205 | */ |
206 | - public function getWebhooks () { |
|
206 | + public function getWebhooks() { |
|
207 | 207 | return $this->loadAll(ProjectWebhook::class, 'webhooks', [ |
208 | 208 | 'workspace' => $this->getWorkspace()->getGid(), |
209 | 209 | 'resource' => $this->getGid() |
210 | 210 | ]); |
211 | 211 | } |
212 | 212 | |
213 | - public function isBoard (): bool { |
|
213 | + public function isBoard(): bool { |
|
214 | 214 | return $this->getLayout() === self::LAYOUT_BOARD; |
215 | 215 | } |
216 | 216 | |
217 | - public function isList (): bool { |
|
217 | + public function isList(): bool { |
|
218 | 218 | return $this->getLayout() === self::LAYOUT_LIST; |
219 | 219 | } |
220 | 220 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @depends after-create |
223 | 223 | * @return Section |
224 | 224 | */ |
225 | - public function newSection () { |
|
225 | + public function newSection() { |
|
226 | 226 | return $this->factory(Section::class, ['project' => $this]); |
227 | 227 | } |
228 | 228 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @depends after-create |
231 | 231 | * @return Status |
232 | 232 | */ |
233 | - public function newStatus () { |
|
233 | + public function newStatus() { |
|
234 | 234 | return $this->factory(Status::class); |
235 | 235 | } |
236 | 236 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @depends after-create |
241 | 241 | * @return Task |
242 | 242 | */ |
243 | - public function newTask () { |
|
243 | + public function newTask() { |
|
244 | 244 | return $this->getDefaultSection()->newTask(); |
245 | 245 | } |
246 | 246 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param User $user |
250 | 250 | * @return $this |
251 | 251 | */ |
252 | - public function removeMember (User $user) { |
|
252 | + public function removeMember(User $user) { |
|
253 | 253 | return $this->removeMembers([$user]); |
254 | 254 | } |
255 | 255 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param User[] $users |
259 | 259 | * @return $this |
260 | 260 | */ |
261 | - public function removeMembers (array $users) { |
|
261 | + public function removeMembers(array $users) { |
|
262 | 262 | return $this->_removeWithPost("{$this}/removeMembers", [ |
263 | 263 | 'members' => array_column($users, 'gid') |
264 | 264 | ], 'members', $users); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @param callable $filter `fn( Section $section ): bool` |
269 | 269 | * @return Section[] |
270 | 270 | */ |
271 | - public function selectSections (callable $filter) { |
|
271 | + public function selectSections(callable $filter) { |
|
272 | 272 | return $this->_select($this->getSections(), $filter); |
273 | 273 | } |
274 | 274 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param callable $filter `fn( Status $status ): bool` |
277 | 277 | * @return Status[] |
278 | 278 | */ |
279 | - public function selectStatuses (callable $filter) { |
|
279 | + public function selectStatuses(callable $filter) { |
|
280 | 280 | return $this->_select($this->getStatuses(), $filter); |
281 | 281 | } |
282 | 282 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @param array $apiFilter Pre-filter given to the API to reduce network load. |
286 | 286 | * @return Task[] |
287 | 287 | */ |
288 | - public function selectTasks (callable $filter, array $apiFilter = []) { |
|
288 | + public function selectTasks(callable $filter, array $apiFilter = []) { |
|
289 | 289 | return $this->_select($this->getTasks($apiFilter), $filter); |
290 | 290 | } |
291 | 291 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * @param null|Team $team |
295 | 295 | * @return $this |
296 | 296 | */ |
297 | - public function setTeam (?Team $team) { |
|
297 | + public function setTeam(?Team $team) { |
|
298 | 298 | if ($team and !$this->hasWorkspace()) { |
299 | 299 | $this->setWorkspace($team->getOrganization()); |
300 | 300 | } |
@@ -95,15 +95,15 @@ 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 | - final protected function _getDir (): string { |
|
102 | + final protected function _getDir(): string { |
|
103 | 103 | return 'tasks'; |
104 | 104 | } |
105 | 105 | |
106 | - protected function _save (string $dir = null) { |
|
106 | + protected function _save(string $dir = null) { |
|
107 | 107 | parent::_save($dir); |
108 | 108 | // use isset() to avoid has() fetch. |
109 | 109 | if (isset($this->data['custom_fields'])) { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | return $this; |
116 | 116 | } |
117 | 117 | |
118 | - protected function _setData (array $data): void { |
|
118 | + protected function _setData(array $data): void { |
|
119 | 119 | unset($data['hearted']); // deprecated for likes |
120 | 120 | unset($data['hearts']); // deprecated for likes |
121 | 121 | unset($data['projects']); // redundant, memberships are used instead |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param string $file |
130 | 130 | * @return Attachment |
131 | 131 | */ |
132 | - public function addAttachment (string $file) { |
|
132 | + public function addAttachment(string $file) { |
|
133 | 133 | /** @var Attachment $attachment */ |
134 | 134 | $attachment = $this->factory(Attachment::class, ['parent' => $this]); |
135 | 135 | return $attachment->upload($file); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param string $text |
142 | 142 | * @return Story |
143 | 143 | */ |
144 | - public function addComment (string $text) { |
|
144 | + public function addComment(string $text) { |
|
145 | 145 | return $this->newComment()->setText($text)->create(); |
146 | 146 | } |
147 | 147 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param Task[] $tasks |
153 | 153 | * @return $this |
154 | 154 | */ |
155 | - public function addDependencies (array $tasks) { |
|
155 | + public function addDependencies(array $tasks) { |
|
156 | 156 | $this->api->post("{$this}/addDependencies", ['dependents' => array_column($tasks, 'gid')]); |
157 | 157 | return $this; |
158 | 158 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param Task $task |
165 | 165 | * @return $this |
166 | 166 | */ |
167 | - public function addDependency (Task $task) { |
|
167 | + public function addDependency(Task $task) { |
|
168 | 168 | return $this->addDependencies([$task]); |
169 | 169 | } |
170 | 170 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @param Task $task |
176 | 176 | * @return $this |
177 | 177 | */ |
178 | - public function addDependent (Task $task) { |
|
178 | + public function addDependent(Task $task) { |
|
179 | 179 | return $this->addDependents([$task]); |
180 | 180 | } |
181 | 181 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param Task[] $tasks |
187 | 187 | * @return $this |
188 | 188 | */ |
189 | - public function addDependents (array $tasks) { |
|
189 | + public function addDependents(array $tasks) { |
|
190 | 190 | $this->api->post("{$this}/addDependents", ['dependents' => array_column($tasks, 'gid')]); |
191 | 191 | return $this; |
192 | 192 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param User $user |
198 | 198 | * @return $this |
199 | 199 | */ |
200 | - public function addFollower (User $user) { |
|
200 | + public function addFollower(User $user) { |
|
201 | 201 | return $this->addFollowers([$user]); |
202 | 202 | } |
203 | 203 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param User[] $users |
210 | 210 | * @return $this |
211 | 211 | */ |
212 | - public function addFollowers (array $users) { |
|
212 | + public function addFollowers(array $users) { |
|
213 | 213 | return $this->_addWithPost("{$this}/addFollowers", [ |
214 | 214 | 'followers' => array_column($users, 'gid') |
215 | 215 | ], 'followers', $users); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * @param Tag $tag |
224 | 224 | * @return $this |
225 | 225 | */ |
226 | - public function addTag (Tag $tag) { |
|
226 | + public function addTag(Tag $tag) { |
|
227 | 227 | return $this->_addWithPost("{$this}/addTag", [ |
228 | 228 | 'tag' => $tag->getGid() |
229 | 229 | ], 'tags', [$tag]); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param Section|null $section |
239 | 239 | * @return $this |
240 | 240 | */ |
241 | - public function addToProject (Project $project, Section $section = null) { |
|
241 | + public function addToProject(Project $project, Section $section = null) { |
|
242 | 242 | /** @var Membership $membership */ |
243 | 243 | $membership = $this->factory(Membership::class) |
244 | 244 | ->_set('project', $project) |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @param string $target |
254 | 254 | * @return TaskWebhook |
255 | 255 | */ |
256 | - public function addWebhook (string $target) { |
|
256 | + public function addWebhook(string $target) { |
|
257 | 257 | /** @var TaskWebhook $webhook */ |
258 | 258 | $webhook = $this->factory(TaskWebhook::class); |
259 | 259 | return $webhook->create($this, $target); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param string[] $include |
270 | 270 | * @return Job |
271 | 271 | */ |
272 | - public function duplicate (string $name, array $include) { |
|
272 | + public function duplicate(string $name, array $include) { |
|
273 | 273 | /** @var array $remote */ |
274 | 274 | $remote = $this->api->post("{$this}/duplicate", [ |
275 | 275 | 'name' => $name, |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @depends after-create |
285 | 285 | * @return Attachment[] |
286 | 286 | */ |
287 | - public function getAttachments () { |
|
287 | + public function getAttachments() { |
|
288 | 288 | return $this->loadAll(Attachment::class, "{$this}/attachments"); |
289 | 289 | } |
290 | 290 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * @depends after-create |
295 | 295 | * @return Story[] |
296 | 296 | */ |
297 | - public function getComments () { |
|
297 | + public function getComments() { |
|
298 | 298 | return $this->selectStories(function(Story $story) { |
299 | 299 | return $story->isComment(); |
300 | 300 | }); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @depends after-create |
307 | 307 | * @return Task[] |
308 | 308 | */ |
309 | - public function getDependencies () { |
|
309 | + public function getDependencies() { |
|
310 | 310 | return $this->loadAll(self::class, "{$this}/dependencies"); |
311 | 311 | } |
312 | 312 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @depends after-create |
317 | 317 | * @return Task[] |
318 | 318 | */ |
319 | - public function getDependents () { |
|
319 | + public function getDependents() { |
|
320 | 320 | return $this->loadAll(self::class, "{$this}/dependents"); |
321 | 321 | } |
322 | 322 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @param null|string $token |
328 | 328 | * @return TaskEvent[]|StoryEvent[] |
329 | 329 | */ |
330 | - public function getEvents (&$token) { |
|
330 | + public function getEvents(&$token) { |
|
331 | 331 | return $this->api->sync($this, $token); |
332 | 332 | } |
333 | 333 | |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @return External |
341 | 341 | */ |
342 | - public function getExternal () { |
|
342 | + public function getExternal() { |
|
343 | 343 | return $this->_get('external') ?? $this->data['external'] = $this->factory(External::class); |
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
347 | 347 | * @return Project[] |
348 | 348 | */ |
349 | - public function getProjects () { |
|
349 | + public function getProjects() { |
|
350 | 350 | return array_map(function(Membership $membership) { |
351 | 351 | return $membership->getProject(); |
352 | 352 | }, $this->getMemberships()); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @depends after-create |
359 | 359 | * @return Story[] |
360 | 360 | */ |
361 | - public function getStories () { |
|
361 | + public function getStories() { |
|
362 | 362 | return $this->loadAll(Story::class, "{$this}/stories"); |
363 | 363 | } |
364 | 364 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @depends after-create |
369 | 369 | * @return Task[] |
370 | 370 | */ |
371 | - public function getSubTasks () { |
|
371 | + public function getSubTasks() { |
|
372 | 372 | return $this->loadAll(self::class, "{$this}/subtasks"); |
373 | 373 | } |
374 | 374 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @depends after-create |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public function getUrl (): string { |
|
381 | + public function getUrl(): string { |
|
382 | 382 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
383 | 383 | } |
384 | 384 | |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @depends after-create |
389 | 389 | * @return TaskWebhook[] |
390 | 390 | */ |
391 | - public function getWebhooks () { |
|
391 | + public function getWebhooks() { |
|
392 | 392 | return $this->loadAll(TaskWebhook::class, 'webhooks', [ |
393 | 393 | 'workspace' => $this->getWorkspace()->getGid(), |
394 | 394 | 'resource' => $this->getGid() |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | /** |
399 | 399 | * @return bool |
400 | 400 | */ |
401 | - public function isRenderedAsSeparator (): bool { |
|
401 | + public function isRenderedAsSeparator(): bool { |
|
402 | 402 | return $this->_is('is_rendered_as_separator'); |
403 | 403 | } |
404 | 404 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @depends after-create |
409 | 409 | * @return Story |
410 | 410 | */ |
411 | - public function newComment () { |
|
411 | + public function newComment() { |
|
412 | 412 | /** @var Story $comment */ |
413 | 413 | $comment = $this->factory(Story::class, ['resource_subtype' => Story::TYPE_COMMENT_ADDED]); |
414 | 414 | return $comment->_set('task', $this); |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | * @depends after-create |
421 | 421 | * @return Task |
422 | 422 | */ |
423 | - public function newSubTask () { |
|
423 | + public function newSubTask() { |
|
424 | 424 | /** @var Task $sub */ |
425 | 425 | $sub = $this->factory(self::class); |
426 | 426 | return $sub->setParent($this); |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * @param Task[] $tasks |
434 | 434 | * @return $this |
435 | 435 | */ |
436 | - public function removeDependencies (array $tasks) { |
|
436 | + public function removeDependencies(array $tasks) { |
|
437 | 437 | $this->api->post("{$this}/removeDependencies", ['dependencies' => array_column($tasks, 'gid')]); |
438 | 438 | return $this; |
439 | 439 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @param Task $task |
446 | 446 | * @return $this |
447 | 447 | */ |
448 | - public function removeDependency (Task $task) { |
|
448 | + public function removeDependency(Task $task) { |
|
449 | 449 | return $this->removeDependencies([$task]); |
450 | 450 | } |
451 | 451 | |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | * @param Task $task |
457 | 457 | * @return $this |
458 | 458 | */ |
459 | - public function removeDependent (Task $task) { |
|
459 | + public function removeDependent(Task $task) { |
|
460 | 460 | return $this->removeDependents([$task]); |
461 | 461 | } |
462 | 462 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | * @param Task[] $tasks |
468 | 468 | * @return $this |
469 | 469 | */ |
470 | - public function removeDependents (array $tasks) { |
|
470 | + public function removeDependents(array $tasks) { |
|
471 | 471 | $this->api->post("{$this}/removeDependents", ['dependents' => array_column($tasks, 'gid')]); |
472 | 472 | return $this; |
473 | 473 | } |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @param User $user |
479 | 479 | * @return $this |
480 | 480 | */ |
481 | - public function removeFollower (User $user) { |
|
481 | + public function removeFollower(User $user) { |
|
482 | 482 | return $this->removeFollowers([$user]); |
483 | 483 | } |
484 | 484 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * @param User[] $users |
491 | 491 | * @return $this |
492 | 492 | */ |
493 | - public function removeFollowers (array $users) { |
|
493 | + public function removeFollowers(array $users) { |
|
494 | 494 | return $this->_removeWithPost("{$this}/removeFollowers", [ |
495 | 495 | 'followers' => array_column($users, 'gid') |
496 | 496 | ], 'followers', $users); |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | * @param Project $project |
505 | 505 | * @return $this |
506 | 506 | */ |
507 | - public function removeFromProject (Project $project) { |
|
507 | + public function removeFromProject(Project $project) { |
|
508 | 508 | return $this->_removeWithPost("{$this}/removeProject", [ |
509 | 509 | 'project' => $project->getGid() |
510 | 510 | ], 'memberships', function(Membership $membership) use ($project) { |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @param Tag $tag |
521 | 521 | * @return $this |
522 | 522 | */ |
523 | - public function removeTag (Tag $tag) { |
|
523 | + public function removeTag(Tag $tag) { |
|
524 | 524 | return $this->_removeWithPost("{$this}/removeTag", [ |
525 | 525 | 'tag' => $tag->getGid() |
526 | 526 | ], 'tags', [$tag]); |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | * @param callable $filter `fn( Attachment $attachment): bool` |
531 | 531 | * @return Attachment[] |
532 | 532 | */ |
533 | - public function selectAttachments (callable $filter) { |
|
533 | + public function selectAttachments(callable $filter) { |
|
534 | 534 | return $this->_select($this->getAttachments(), $filter); |
535 | 535 | } |
536 | 536 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | * @param callable $filter `fn( Story $comment ): bool` |
539 | 539 | * @return Story[] |
540 | 540 | */ |
541 | - public function selectComments (callable $filter) { |
|
541 | + public function selectComments(callable $filter) { |
|
542 | 542 | return $this->_select($this->getComments(), $filter); |
543 | 543 | } |
544 | 544 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @param callable $filter `fn( Task $dependency ): bool` |
547 | 547 | * @return Task[] |
548 | 548 | */ |
549 | - public function selectDependencies (callable $filter) { |
|
549 | + public function selectDependencies(callable $filter) { |
|
550 | 550 | return $this->_select($this->getDependencies(), $filter); |
551 | 551 | } |
552 | 552 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | * @param callable $filter `fn( Task $dependent ): bool` |
555 | 555 | * @return Task[] |
556 | 556 | */ |
557 | - public function selectDependents (callable $filter) { |
|
557 | + public function selectDependents(callable $filter) { |
|
558 | 558 | return $this->_select($this->getDependents(), $filter); |
559 | 559 | } |
560 | 560 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @param callable $filter `fn( Project $project ): bool` |
563 | 563 | * @return Project[] |
564 | 564 | */ |
565 | - public function selectProjects (callable $filter) { |
|
565 | + public function selectProjects(callable $filter) { |
|
566 | 566 | return $this->_select($this->getProjects(), $filter); |
567 | 567 | } |
568 | 568 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * @param callable $filter `fn( Story $story ): bool` |
571 | 571 | * @return Story[] |
572 | 572 | */ |
573 | - public function selectStories (callable $filter) { |
|
573 | + public function selectStories(callable $filter) { |
|
574 | 574 | return $this->_select($this->getStories(), $filter); |
575 | 575 | } |
576 | 576 | |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | * @param callable $filter `fn( Task $subtask ): bool` |
579 | 579 | * @return Task[] |
580 | 580 | */ |
581 | - public function selectSubTasks (callable $filter) { |
|
581 | + public function selectSubTasks(callable $filter) { |
|
582 | 582 | return $this->_select($this->getSubTasks(), $filter); |
583 | 583 | } |
584 | 584 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * @param null|Task $parent |
590 | 590 | * @return $this |
591 | 591 | */ |
592 | - public function setParent (?self $parent) { |
|
592 | + public function setParent(?self $parent) { |
|
593 | 593 | return $this->_setWithPost("{$this}/setParent", [ |
594 | 594 | 'parent' => $parent |
595 | 595 | ], 'parent', $parent); |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | * @param bool $flag |
600 | 600 | * @return $this |
601 | 601 | */ |
602 | - public function setRenderedAsSeparator (bool $flag) { |
|
602 | + public function setRenderedAsSeparator(bool $flag) { |
|
603 | 603 | return $this->_set('is_rendered_as_separator', $flag); |
604 | 604 | } |
605 | 605 |