@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - abstract public function __toString (): string; |
|
33 | + abstract public function __toString(): string; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @param self $entity |
37 | 37 | * @return bool |
38 | 38 | * @internal pool |
39 | 39 | */ |
40 | - final public function __merge (self $entity): bool { |
|
40 | + final public function __merge(self $entity): bool { |
|
41 | 41 | $old = $this->toArray(); |
42 | 42 | $this->data = array_merge($this->data, array_diff_key($entity->data, $this->diff)); |
43 | 43 | return $this->toArray() !== $old; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $field |
50 | 50 | * @return mixed |
51 | 51 | */ |
52 | - protected function _get (string $field) { |
|
52 | + protected function _get(string $field) { |
|
53 | 53 | if (!array_key_exists($field, $this->data) and $this->hasGid()) { |
54 | 54 | $this->_reload($field); |
55 | 55 | } |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * @param string $field |
61 | 61 | */ |
62 | - protected function _reload (string $field): void { |
|
62 | + protected function _reload(string $field): void { |
|
63 | 63 | $remote = $this->api->get($this, [], ['fields' => static::OPT_FIELDS[$field] ?? $field]); |
64 | 64 | $this->_setField($field, $remote[$field] ?? null); |
65 | 65 | $this->api->getPool()->add($this); |
66 | 66 | } |
67 | 67 | |
68 | - protected function _setData (array $data): void { |
|
68 | + protected function _setData(array $data): void { |
|
69 | 69 | // meaningless once the entity is being created. it's constant. |
70 | 70 | unset($data['resource_type'], $data['type']); |
71 | 71 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | /** |
76 | 76 | * @return null|string |
77 | 77 | */ |
78 | - final public function getGid (): ?string { |
|
78 | + final public function getGid(): ?string { |
|
79 | 79 | return $this->data['gid'] ?? null; |
80 | 80 | } |
81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return string[] |
86 | 86 | */ |
87 | - public function getPoolKeys () { |
|
87 | + public function getPoolKeys() { |
|
88 | 88 | return [$this->getGid(), (string)$this]; |
89 | 89 | } |
90 | 90 | |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return string |
95 | 95 | */ |
96 | - final public function getResourceType (): string { |
|
96 | + final public function getResourceType(): string { |
|
97 | 97 | return static::TYPE; |
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @return bool |
102 | 102 | */ |
103 | - final public function hasGid (): bool { |
|
103 | + final public function hasGid(): bool { |
|
104 | 104 | return isset($this->data['gid']); |
105 | 105 | } |
106 | 106 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @depends after-create |
111 | 111 | * @return $this |
112 | 112 | */ |
113 | - public function reload () { |
|
113 | + public function reload() { |
|
114 | 114 | $remote = $this->api->get($this, [], ['expand' => 'this']); |
115 | 115 | if (!isset($remote['gid'])) { // null and dir guard |
116 | 116 | $this->api->getPool()->remove($this->getPoolKeys()); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - final public function __toString (): string { |
|
41 | + final public function __toString(): string { |
|
42 | 42 | return "workspaces/{$this->getGid()}"; |
43 | 43 | } |
44 | 44 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return OrganizationExport |
51 | 51 | */ |
52 | - public function export () { |
|
52 | + public function export() { |
|
53 | 53 | /** @var OrganizationExport $export */ |
54 | 54 | $export = $this->api->factory($this, OrganizationExport::class); |
55 | 55 | return $export->create($this); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param int $limit 1-100 |
70 | 70 | * @return array|AbstractEntity[] |
71 | 71 | */ |
72 | - protected function find (string $class, string $text, int $limit = 20) { |
|
72 | + protected function find(string $class, string $text, int $limit = 20) { |
|
73 | 73 | return $this->api->loadAll($this, $class, "{$this}/typeahead", [ |
74 | 74 | 'resource_type' => $class::TYPE, |
75 | 75 | 'query' => $text, |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param int $limit 1-100 |
85 | 85 | * @return CustomField[] |
86 | 86 | */ |
87 | - public function findCustomFields (string $text, int $limit = 20) { |
|
87 | + public function findCustomFields(string $text, int $limit = 20) { |
|
88 | 88 | return $this->find(CustomField::class, $text, $limit); |
89 | 89 | } |
90 | 90 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param int $limit 1-100 |
96 | 96 | * @return Portfolio[] |
97 | 97 | */ |
98 | - public function findPortfolios (string $text, int $limit = 20) { |
|
98 | + public function findPortfolios(string $text, int $limit = 20) { |
|
99 | 99 | return $this->find(Portfolio::class, $text, $limit); |
100 | 100 | } |
101 | 101 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param int $limit 1-100 |
107 | 107 | * @return Project[] |
108 | 108 | */ |
109 | - public function findProjects (string $text, int $limit = 20) { |
|
109 | + public function findProjects(string $text, int $limit = 20) { |
|
110 | 110 | return $this->find(Project::class, $text, $limit); |
111 | 111 | } |
112 | 112 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param int $limit 1-100 |
118 | 118 | * @return Tag[] |
119 | 119 | */ |
120 | - public function findTags (string $text, int $limit = 20) { |
|
120 | + public function findTags(string $text, int $limit = 20) { |
|
121 | 121 | return $this->find(Tag::class, $text, $limit); |
122 | 122 | } |
123 | 123 | |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | * @param int $limit 1-100 |
129 | 129 | * @return Task[] |
130 | 130 | */ |
131 | - public function findTasks (string $text, int $limit = 20) { |
|
131 | + public function findTasks(string $text, int $limit = 20) { |
|
132 | 132 | return $this->find(Task::class, $text, $limit); |
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | 136 | * @return CustomField[] |
137 | 137 | */ |
138 | - public function getCustomFields () { |
|
138 | + public function getCustomFields() { |
|
139 | 139 | return $this->api->loadAll($this, CustomField::class, "{$this}/custom_fields"); |
140 | 140 | } |
141 | 141 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return Portfolio[] |
146 | 146 | */ |
147 | - public function getPortfolios () { |
|
147 | + public function getPortfolios() { |
|
148 | 148 | return $this->api->loadAll($this, Portfolio::class, "portfolios", [ |
149 | 149 | 'workspace' => $this->getGid(), |
150 | 150 | 'owner' => $this->api->getMe()->getGid() // the only allowed value, but still required. |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param array $filter |
158 | 158 | * @return Project[] |
159 | 159 | */ |
160 | - public function getProjects (array $filter = Project::GET_ACTIVE) { |
|
160 | + public function getProjects(array $filter = Project::GET_ACTIVE) { |
|
161 | 161 | $filter['workspace'] = $this->getGid(); |
162 | 162 | return $this->api->loadAll($this, Project::class, 'projects', $filter); |
163 | 163 | } |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | /** |
166 | 166 | * @return Tag[] |
167 | 167 | */ |
168 | - public function getTags () { |
|
168 | + public function getTags() { |
|
169 | 169 | return $this->api->loadAll($this, Tag::class, 'tags', ['workspace' => $this->getGid()]); |
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | 173 | * @return Team[] |
174 | 174 | */ |
175 | - public function getTeams () { |
|
175 | + public function getTeams() { |
|
176 | 176 | return $this->api->loadAll($this, Team::class, "organizations/{$this->getGid()}/teams"); |
177 | 177 | } |
178 | 178 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param string $email |
181 | 181 | * @return null|User |
182 | 182 | */ |
183 | - public function getUserByEmail (string $email) { |
|
183 | + public function getUserByEmail(string $email) { |
|
184 | 184 | return $this->api->getPool()->get("users/{$email}", $this, function() use ($email) { |
185 | 185 | foreach ($this->getUsers() as $user) { |
186 | 186 | if ($user->getEmail() === $email) { |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | /** |
195 | 195 | * @return User[] |
196 | 196 | */ |
197 | - public function getUsers () { |
|
197 | + public function getUsers() { |
|
198 | 198 | return $this->api->loadAll($this, User::class, "{$this}/users"); |
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
202 | 202 | * @return ProjectWebhook[]|TaskWebhook[] |
203 | 203 | */ |
204 | - public function getWebhooks () { |
|
204 | + public function getWebhooks() { |
|
205 | 205 | /** @var array $all */ |
206 | 206 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
207 | 207 | return array_map(function(array $each) { |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | /** |
219 | 219 | * @return bool |
220 | 220 | */ |
221 | - final public function isOrganization (): bool { |
|
221 | + final public function isOrganization(): bool { |
|
222 | 222 | return $this->_is('is_organization'); |
223 | 223 | } |
224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return CustomField |
229 | 229 | */ |
230 | - public function newCustomField () { |
|
230 | + public function newCustomField() { |
|
231 | 231 | /** @var CustomField $field */ |
232 | 232 | $field = $this->api->factory($this, CustomField::class); |
233 | 233 | return $field->setWorkspace($this); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return Portfolio |
240 | 240 | */ |
241 | - public function newPortfolio () { |
|
241 | + public function newPortfolio() { |
|
242 | 242 | /** @var Portfolio $portfolio */ |
243 | 243 | $portfolio = $this->api->factory($this, Portfolio::class); |
244 | 244 | return $portfolio->setWorkspace($this); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return Project |
251 | 251 | */ |
252 | - public function newProject () { |
|
252 | + public function newProject() { |
|
253 | 253 | /** @var Project $project */ |
254 | 254 | $project = $this->api->factory($this, Project::class); |
255 | 255 | return $project->setWorkspace($this); |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return Tag |
262 | 262 | */ |
263 | - public function newTag () { |
|
263 | + public function newTag() { |
|
264 | 264 | /** @var Tag $tag */ |
265 | 265 | $tag = $this->api->factory($this, Tag::class); |
266 | 266 | return $tag->setWorkspace($this); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return Task |
273 | 273 | */ |
274 | - public function newTask () { |
|
274 | + public function newTask() { |
|
275 | 275 | /** @var Task $task */ |
276 | 276 | $task = $this->api->factory($this, Task::class); |
277 | 277 | return $task->setWorkspace($this); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return string |
94 | 94 | */ |
95 | - final public function __toString (): string { |
|
95 | + final public function __toString(): string { |
|
96 | 96 | return "projects/{$this->getGid()}"; |
97 | 97 | } |
98 | 98 | |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string |
103 | 103 | */ |
104 | - final protected function _getDir (): string { |
|
104 | + final protected function _getDir(): string { |
|
105 | 105 | return 'projects'; |
106 | 106 | } |
107 | 107 | |
108 | - protected function _setData (array $data): void { |
|
108 | + protected function _setData(array $data): void { |
|
109 | 109 | // this is always empty. fields are in the settings, values are in tasks. |
110 | 110 | unset($data['custom_fields']); |
111 | 111 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @param User $user |
121 | 121 | * @return $this |
122 | 122 | */ |
123 | - public function addMember (User $user) { |
|
123 | + public function addMember(User $user) { |
|
124 | 124 | return $this->addMembers([$user]); |
125 | 125 | } |
126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param User[] $users |
130 | 130 | * @return $this |
131 | 131 | */ |
132 | - public function addMembers (array $users) { |
|
132 | + public function addMembers(array $users) { |
|
133 | 133 | return $this->_addWithPost("{$this}/addMembers", [ |
134 | 134 | 'members' => array_column($users, 'gid') |
135 | 135 | ], 'members', $users); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string $target |
141 | 141 | * @return ProjectWebhook |
142 | 142 | */ |
143 | - public function addWebhook (string $target) { |
|
143 | + public function addWebhook(string $target) { |
|
144 | 144 | /** @var ProjectWebhook $webhook */ |
145 | 145 | $webhook = $this->api->factory($this, ProjectWebhook::class); |
146 | 146 | return $webhook->create($this, $target); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param array $schedule |
166 | 166 | * @return Job |
167 | 167 | */ |
168 | - public function duplicate (string $name, array $include, Team $team = null, array $schedule = []) { |
|
168 | + public function duplicate(string $name, array $include, Team $team = null, array $schedule = []) { |
|
169 | 169 | $data = ['name' => $name]; |
170 | 170 | if ($team) { |
171 | 171 | $data['team'] = $team->getGid(); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @depends after-create |
186 | 186 | * @return Section |
187 | 187 | */ |
188 | - public function getDefaultSection () { |
|
188 | + public function getDefaultSection() { |
|
189 | 189 | return $this->defaultSection ?? $this->defaultSection = $this->getSections(1)[0]; |
190 | 190 | } |
191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param null|string $token |
199 | 199 | * @return Event[] |
200 | 200 | */ |
201 | - public function getEvents (&$token) { |
|
201 | + public function getEvents(&$token) { |
|
202 | 202 | return $this->api->sync($this->getGid(), $token); |
203 | 203 | } |
204 | 204 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param int $limit |
211 | 211 | * @return Traversable|Section[] |
212 | 212 | */ |
213 | - public function getIterator (int $limit = PHP_INT_MAX) { |
|
213 | + public function getIterator(int $limit = PHP_INT_MAX) { |
|
214 | 214 | return $this->api->loadEach($this, Section::class, "{$this}/sections", ['limit' => $limit]); |
215 | 215 | } |
216 | 216 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param int $limit |
220 | 220 | * @return Section[] |
221 | 221 | */ |
222 | - public function getSections (int $limit = PHP_INT_MAX) { |
|
222 | + public function getSections(int $limit = PHP_INT_MAX) { |
|
223 | 223 | return iterator_to_array($this->getIterator($limit)); |
224 | 224 | } |
225 | 225 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @depends after-create |
228 | 228 | * @return Status[] |
229 | 229 | */ |
230 | - public function getStatuses () { |
|
230 | + public function getStatuses() { |
|
231 | 231 | return $this->api->loadAll($this, Status::class, "{$this}/project_statuses"); |
232 | 232 | } |
233 | 233 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @depends after-create |
236 | 236 | * @return TaskCounts |
237 | 237 | */ |
238 | - public function getTaskCounts () { |
|
238 | + public function getTaskCounts() { |
|
239 | 239 | /** @var array $remote */ |
240 | 240 | $remote = $this->api->get("{$this}/task_counts", [], TaskCounts::OPT); |
241 | 241 | return $this->api->factory($this, TaskCounts::class, $remote); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @param array $filter |
249 | 249 | * @return Task[] |
250 | 250 | */ |
251 | - public function getTasks (array $filter = Task::GET_INCOMPLETE) { |
|
251 | + public function getTasks(array $filter = Task::GET_INCOMPLETE) { |
|
252 | 252 | $filter['project'] = $this->getGid(); |
253 | 253 | return $this->api->loadAll($this, Task::class, "tasks", $filter); |
254 | 254 | } |
@@ -257,25 +257,25 @@ discard block |
||
257 | 257 | * @depends after-create |
258 | 258 | * @return string |
259 | 259 | */ |
260 | - public function getUrl (): string { |
|
260 | + public function getUrl(): string { |
|
261 | 261 | return "https://app.asana.com/0/{$this->getGid()}"; |
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | 265 | * @return ProjectWebhook[] |
266 | 266 | */ |
267 | - public function getWebhooks () { |
|
267 | + public function getWebhooks() { |
|
268 | 268 | return $this->api->loadAll($this, ProjectWebhook::class, 'webhooks', [ |
269 | 269 | 'workspace' => $this->getWorkspace()->getGid(), |
270 | 270 | 'resource' => $this->getGid() |
271 | 271 | ]); |
272 | 272 | } |
273 | 273 | |
274 | - final public function isBoard (): bool { |
|
274 | + final public function isBoard(): bool { |
|
275 | 275 | return $this->getLayout() === self::LAYOUT_BOARD; |
276 | 276 | } |
277 | 277 | |
278 | - final public function isList (): bool { |
|
278 | + final public function isList(): bool { |
|
279 | 279 | return $this->getLayout() === self::LAYOUT_LIST; |
280 | 280 | } |
281 | 281 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @depends after-create |
286 | 286 | * @return Section |
287 | 287 | */ |
288 | - public function newSection () { |
|
288 | + public function newSection() { |
|
289 | 289 | return $this->api->factory($this, Section::class, ['project' => $this]); |
290 | 290 | } |
291 | 291 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * @depends after-create |
296 | 296 | * @return Status |
297 | 297 | */ |
298 | - public function newStatus () { |
|
298 | + public function newStatus() { |
|
299 | 299 | return $this->api->factory($this, Status::class); |
300 | 300 | } |
301 | 301 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @depends after-create |
306 | 306 | * @return Task |
307 | 307 | */ |
308 | - public function newTask () { |
|
308 | + public function newTask() { |
|
309 | 309 | return $this->getDefaultSection()->newTask(); |
310 | 310 | } |
311 | 311 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @param User $user |
315 | 315 | * @return $this |
316 | 316 | */ |
317 | - public function removeMember (User $user) { |
|
317 | + public function removeMember(User $user) { |
|
318 | 318 | return $this->removeMembers([$user]); |
319 | 319 | } |
320 | 320 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param User[] $users |
324 | 324 | * @return $this |
325 | 325 | */ |
326 | - public function removeMembers (array $users) { |
|
326 | + public function removeMembers(array $users) { |
|
327 | 327 | return $this->_removeWithPost("{$this}/removeMembers", [ |
328 | 328 | 'members' => array_column($users, 'gid') |
329 | 329 | ], 'members', $users); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param null|Team $team |
335 | 335 | * @return $this |
336 | 336 | */ |
337 | - public function setTeam (?Team $team) { |
|
337 | + public function setTeam(?Team $team) { |
|
338 | 338 | if ($team and !$this->hasWorkspace()) { |
339 | 339 | $this->setWorkspace($team->getOrganization()); |
340 | 340 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $token |
44 | 44 | * @param null|Pool $pool |
45 | 45 | */ |
46 | - public function __construct (string $token, Pool $pool = null) { |
|
46 | + public function __construct(string $token, Pool $pool = null) { |
|
47 | 47 | $this->token = $token; |
48 | 48 | $this->pool = $pool ?? new Pool(); |
49 | 49 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @return null|array |
58 | 58 | * @internal |
59 | 59 | */ |
60 | - protected function _exec (string $method, string $path, array $curlOpts = []) { |
|
60 | + protected function _exec(string $method, string $path, array $curlOpts = []) { |
|
61 | 61 | $log = $this->getLog(); |
62 | 62 | $log->log(LOG_DEBUG, "{$method} {$path}", $curlOpts); |
63 | 63 | /** @var resource $ch */ |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | switch ($curlInfo['http_code']) { |
89 | 89 | case 200: |
90 | 90 | case 201: |
91 | - return json_decode($body, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
91 | + return json_decode($body, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
92 | 92 | case 404: |
93 | 93 | return null; |
94 | 94 | case 429: |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @param string $path |
109 | 109 | */ |
110 | - public function delete (string $path): void { |
|
110 | + public function delete(string $path): void { |
|
111 | 111 | $this->_exec('DELETE', $path); |
112 | 112 | } |
113 | 113 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param array $data |
122 | 122 | * @return mixed|Data|AbstractEntity |
123 | 123 | */ |
124 | - public function factory ($caller, string $class, array $data = []) { |
|
124 | + public function factory($caller, string $class, array $data = []) { |
|
125 | 125 | return new $class($caller, $data); |
126 | 126 | } |
127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param array $opt |
134 | 134 | * @return null|array |
135 | 135 | */ |
136 | - public function get (string $path, array $query = [], array $opt = []) { |
|
136 | + public function get(string $path, array $query = [], array $opt = []) { |
|
137 | 137 | foreach ($opt as $name => $value) { |
138 | 138 | $query["opt_{$name}"] = $value; |
139 | 139 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param string $gid |
148 | 148 | * @return null|Attachment |
149 | 149 | */ |
150 | - public function getAttachment (string $gid) { |
|
150 | + public function getAttachment(string $gid) { |
|
151 | 151 | return $this->load($this, Attachment::class, "attachments/{$gid}"); |
152 | 152 | } |
153 | 153 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string $gid |
158 | 158 | * @return null|CustomField |
159 | 159 | */ |
160 | - public function getCustomField (string $gid) { |
|
160 | + public function getCustomField(string $gid) { |
|
161 | 161 | return $this->load($this, CustomField::class, "custom_fields/{$gid}"); |
162 | 162 | } |
163 | 163 | |
@@ -168,28 +168,28 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return Workspace |
170 | 170 | */ |
171 | - public function getDefaultWorkspace () { |
|
171 | + public function getDefaultWorkspace() { |
|
172 | 172 | return $this->getMe()->getDefaultWorkspace(); |
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | 176 | * @return LoggerInterface |
177 | 177 | */ |
178 | - public function getLog () { |
|
178 | + public function getLog() { |
|
179 | 179 | return $this->log ?? $this->log = new NullLogger(); |
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
183 | 183 | * @return User |
184 | 184 | */ |
185 | - public function getMe () { |
|
185 | + public function getMe() { |
|
186 | 186 | return $this->getUser('me'); |
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | 190 | * @return Pool |
191 | 191 | */ |
192 | - public function getPool () { |
|
192 | + public function getPool() { |
|
193 | 193 | return $this->pool; |
194 | 194 | } |
195 | 195 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param string $gid |
200 | 200 | * @return null|Portfolio |
201 | 201 | */ |
202 | - public function getPortfolio (string $gid) { |
|
202 | + public function getPortfolio(string $gid) { |
|
203 | 203 | return $this->load($this, Portfolio::class, "portfolios/{$gid}"); |
204 | 204 | } |
205 | 205 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param string $gid |
210 | 210 | * @return null|Project |
211 | 211 | */ |
212 | - public function getProject (string $gid) { |
|
212 | + public function getProject(string $gid) { |
|
213 | 213 | return $this->load($this, Project::class, "projects/{$gid}"); |
214 | 214 | } |
215 | 215 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param string $gid |
220 | 220 | * @return null|Section |
221 | 221 | */ |
222 | - public function getSection (string $gid) { |
|
222 | + public function getSection(string $gid) { |
|
223 | 223 | return $this->load($this, Section::class, "sections/{$gid}"); |
224 | 224 | } |
225 | 225 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @param string $gid |
230 | 230 | * @return null|Story |
231 | 231 | */ |
232 | - public function getStory (string $gid) { |
|
232 | + public function getStory(string $gid) { |
|
233 | 233 | return $this->load($this, Story::class, "stories/{$gid}"); |
234 | 234 | } |
235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param string $gid |
240 | 240 | * @return null|Tag |
241 | 241 | */ |
242 | - public function getTag (string $gid) { |
|
242 | + public function getTag(string $gid) { |
|
243 | 243 | return $this->load($this, Tag::class, "tags/{$gid}"); |
244 | 244 | } |
245 | 245 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param string $gid |
250 | 250 | * @return null|Task |
251 | 251 | */ |
252 | - public function getTask (string $gid) { |
|
252 | + public function getTask(string $gid) { |
|
253 | 253 | return $this->load($this, Task::class, "tasks/{$gid}"); |
254 | 254 | } |
255 | 255 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param string $gid |
260 | 260 | * @return null|TaskList |
261 | 261 | */ |
262 | - public function getTaskList (string $gid) { |
|
262 | + public function getTaskList(string $gid) { |
|
263 | 263 | return $this->load($this, TaskList::class, "user_task_lists/{$gid}"); |
264 | 264 | } |
265 | 265 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param string $gid |
270 | 270 | * @return null|Team |
271 | 271 | */ |
272 | - public function getTeam (string $gid) { |
|
272 | + public function getTeam(string $gid) { |
|
273 | 273 | return $this->load($this, Team::class, "teams/{$gid}"); |
274 | 274 | } |
275 | 275 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @param string $gid |
280 | 280 | * @return null|User |
281 | 281 | */ |
282 | - public function getUser (string $gid) { |
|
282 | + public function getUser(string $gid) { |
|
283 | 283 | return $this->load($this, User::class, "users/{$gid}"); |
284 | 284 | } |
285 | 285 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param string $gid |
288 | 288 | * @return ProjectWebhook|TaskWebhook |
289 | 289 | */ |
290 | - public function getWebhook (string $gid) { |
|
290 | + public function getWebhook(string $gid) { |
|
291 | 291 | return $this->pool->get($gid, $this, function() use ($gid) { |
292 | 292 | static $classes = [ |
293 | 293 | Project::TYPE => ProjectWebhook::class, |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @param array $data |
309 | 309 | * @return Event |
310 | 310 | */ |
311 | - public function getWebhookEvent (array $data) { |
|
311 | + public function getWebhookEvent(array $data) { |
|
312 | 312 | return $this->factory($this, Event::class, $data); |
313 | 313 | } |
314 | 314 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @param string $gid |
319 | 319 | * @return null|Workspace |
320 | 320 | */ |
321 | - public function getWorkspace (string $gid) { |
|
321 | + public function getWorkspace(string $gid) { |
|
322 | 322 | return $this->load($this, Workspace::class, "workspaces/{$gid}"); |
323 | 323 | } |
324 | 324 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @param array $query |
332 | 332 | * @return null|mixed|AbstractEntity |
333 | 333 | */ |
334 | - public function load ($caller, string $class, string $path, array $query = []) { |
|
334 | + public function load($caller, string $class, string $path, array $query = []) { |
|
335 | 335 | $key = rtrim($path . '?' . http_build_query($query), '?'); |
336 | 336 | return $this->pool->get($key, $caller, function($caller) use ($class, $path, $query) { |
337 | 337 | if ($data = $this->get($path, $query, ['expand' => 'this'])) { |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @param array $query |
351 | 351 | * @return array|AbstractEntity[] |
352 | 352 | */ |
353 | - public function loadAll ($caller, string $class, string $path, array $query = []) { |
|
353 | + public function loadAll($caller, string $class, string $path, array $query = []) { |
|
354 | 354 | return iterator_to_array($this->loadEach(...func_get_args())); |
355 | 355 | } |
356 | 356 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param array $query `limit` can exceed `100` here. |
366 | 366 | * @return Generator|AbstractEntity[] |
367 | 367 | */ |
368 | - public function loadEach ($caller, string $class, string $path, array $query = []) { |
|
368 | + public function loadEach($caller, string $class, string $path, array $query = []) { |
|
369 | 369 | $query['opt_expand'] = 'this'; |
370 | 370 | $remain = $query['limit'] ?? PHP_INT_MAX; |
371 | 371 | do { |
@@ -389,13 +389,13 @@ discard block |
||
389 | 389 | * @param array $opt |
390 | 390 | * @return null|array |
391 | 391 | */ |
392 | - public function post (string $path, array $data = [], array $opt = []) { |
|
392 | + public function post(string $path, array $data = [], array $opt = []) { |
|
393 | 393 | $response = $this->_exec('POST', $path, [ |
394 | 394 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
395 | 395 | CURLOPT_POSTFIELDS => json_encode([ |
396 | 396 | 'options' => $opt, |
397 | 397 | 'data' => $data |
398 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
398 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
399 | 399 | ]); |
400 | 400 | return $response['data'] ?? null; |
401 | 401 | } |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | * @param array $opt |
409 | 409 | * @return null|array |
410 | 410 | */ |
411 | - public function put (string $path, array $data = [], array $opt = []) { |
|
411 | + public function put(string $path, array $data = [], array $opt = []) { |
|
412 | 412 | $response = $this->_exec('PUT', $path, [ |
413 | 413 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
414 | 414 | CURLOPT_POSTFIELDS => json_encode([ |
415 | 415 | 'options' => $opt, |
416 | 416 | 'data' => $data |
417 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
417 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
418 | 418 | ]); |
419 | 419 | return $response['data'] ?? null; |
420 | 420 | } |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | /** |
423 | 423 | * @param LoggerInterface $log |
424 | 424 | */ |
425 | - public function setLog (LoggerInterface $log) { |
|
425 | + public function setLog(LoggerInterface $log) { |
|
426 | 426 | $this->log = $log; |
427 | 427 | } |
428 | 428 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * @param null|string $token Updated to the new token. |
439 | 439 | * @return Event[] |
440 | 440 | */ |
441 | - public function sync (string $gid, ?string &$token) { |
|
441 | + public function sync(string $gid, ?string &$token) { |
|
442 | 442 | try { |
443 | 443 | /** @var array $remote Asana throws 400 for missing entities. */ |
444 | 444 | $remote = $this->_exec('GET', 'events?' . http_build_query([ |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | } |
450 | 450 | catch (AsanaError $error) { |
451 | 451 | if ($error->getCode() === 412) { |
452 | - $remote = json_decode($error->getMessage(), true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
452 | + $remote = json_decode($error->getMessage(), true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
453 | 453 | if (!isset($token)) { |
454 | 454 | // API docs say: "The response will be the same as for an expired sync token." |
455 | 455 | // The caller knowingly gave a null token, so we don't need to rethrow. |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @param string $to |
479 | 479 | * @return array |
480 | 480 | */ |
481 | - public function upload (string $file, string $to) { |
|
481 | + public function upload(string $file, string $to) { |
|
482 | 482 | return $this->_exec('POST', $to, [ |
483 | 483 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
484 | 484 | ])['data']; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param Project $project |
51 | 51 | * @param array $data |
52 | 52 | */ |
53 | - public function __construct (Project $project, array $data = []) { |
|
53 | + public function __construct(Project $project, array $data = []) { |
|
54 | 54 | $this->project = $project; |
55 | 55 | parent::__construct($project, $data); |
56 | 56 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return string |
62 | 62 | */ |
63 | - final public function __toString (): string { |
|
63 | + final public function __toString(): string { |
|
64 | 64 | return "project_statuses/{$this->getGid()}"; |
65 | 65 | } |
66 | 66 | |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return string |
71 | 71 | */ |
72 | - final protected function _getDir (): string { |
|
72 | + final protected function _getDir(): string { |
|
73 | 73 | return "{$this->project}/project_statuses"; |
74 | 74 | } |
75 | 75 | |
76 | - protected function _setData (array $data): void { |
|
76 | + protected function _setData(array $data): void { |
|
77 | 77 | // redundant, prefer created_by |
78 | 78 | unset($data['author']); |
79 | 79 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @return Project |
85 | 85 | */ |
86 | - public function getProject () { |
|
86 | + public function getProject() { |
|
87 | 87 | return $this->project; |
88 | 88 | } |
89 | 89 | } |
90 | 90 | \ No newline at end of file |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return string |
38 | 38 | */ |
39 | - final public function __toString (): string { |
|
39 | + final public function __toString(): string { |
|
40 | 40 | return "sections/{$this->getGid()}"; |
41 | 41 | } |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return string |
47 | 47 | */ |
48 | - final protected function _getDir (): string { |
|
48 | + final protected function _getDir(): string { |
|
49 | 49 | return "{$this->getProject()}/sections"; |
50 | 50 | } |
51 | 51 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param array $filter |
54 | 54 | * @return Traversable|Task[] |
55 | 55 | */ |
56 | - public function getIterator (array $filter = Task::GET_INCOMPLETE) { |
|
56 | + public function getIterator(array $filter = Task::GET_INCOMPLETE) { |
|
57 | 57 | $filter['section'] = $this->getGid(); |
58 | 58 | return $this->api->loadEach($this, Task::class, 'tasks', $filter); |
59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param array $filter |
63 | 63 | * @return Task[] |
64 | 64 | */ |
65 | - public function getTasks (array $filter = Task::GET_INCOMPLETE) { |
|
65 | + public function getTasks(array $filter = Task::GET_INCOMPLETE) { |
|
66 | 66 | return iterator_to_array($this->getIterator($filter)); |
67 | 67 | } |
68 | 68 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @depends after-create |
73 | 73 | * @return Task |
74 | 74 | */ |
75 | - public function newTask () { |
|
75 | + public function newTask() { |
|
76 | 76 | /** @var Task $task */ |
77 | 77 | $task = $this->api->factory($this, Task::class); |
78 | 78 | return $task->addToProject($this); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - final public function __toString (): string { |
|
51 | + final public function __toString(): string { |
|
52 | 52 | return "custom_fields/{$this->getGid()}"; |
53 | 53 | } |
54 | 54 | |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - final protected function _getDir (): string { |
|
60 | + final protected function _getDir(): string { |
|
61 | 61 | return 'custom_fields'; |
62 | 62 | } |
63 | 63 | |
64 | - protected function _setData (array $data): void { |
|
64 | + protected function _setData(array $data): void { |
|
65 | 65 | // strip out field entry values if present. |
66 | 66 | $data = array_intersect_key($data, array_flip([ |
67 | 67 | 'gid', |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param string $name |
83 | 83 | * @return EnumOption |
84 | 84 | */ |
85 | - public function addEnumOption (string $name) { |
|
85 | + public function addEnumOption(string $name) { |
|
86 | 86 | /** @var EnumOption $option */ |
87 | 87 | $option = $this->api->factory($this, EnumOption::class); |
88 | 88 | $option->setName($name); |
@@ -98,35 +98,35 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * @return bool |
100 | 100 | */ |
101 | - final public function hasNotificationsEnabled (): bool { |
|
101 | + final public function hasNotificationsEnabled(): bool { |
|
102 | 102 | return $this->_is('has_notifications_enabled'); |
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | 106 | * @return bool |
107 | 107 | */ |
108 | - final public function isEnum (): bool { |
|
108 | + final public function isEnum(): bool { |
|
109 | 109 | return $this->getResourceSubtype() === self::TYPE_ENUM; |
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
113 | 113 | * @return bool |
114 | 114 | */ |
115 | - final public function isGlobalToWorkspace (): bool { |
|
115 | + final public function isGlobalToWorkspace(): bool { |
|
116 | 116 | return $this->_is('is_global_to_workspace'); |
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
120 | 120 | * @return bool |
121 | 121 | */ |
122 | - final public function isNumber (): bool { |
|
122 | + final public function isNumber(): bool { |
|
123 | 123 | return $this->getResourceSubtype() === self::TYPE_NUMBER; |
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | 127 | * @return bool |
128 | 128 | */ |
129 | - final public function isText (): bool { |
|
129 | + final public function isText(): bool { |
|
130 | 130 | return $this->getResourceSubtype() === self::TYPE_TEXT; |
131 | 131 | } |
132 | 132 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param bool $flag |
135 | 135 | * @return $this |
136 | 136 | */ |
137 | - final public function setGlobalToWorkspace (bool $flag) { |
|
137 | + final public function setGlobalToWorkspace(bool $flag) { |
|
138 | 138 | return $this->_set('is_global_to_workspace', $flag); |
139 | 139 | } |
140 | 140 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param bool $flag |
143 | 143 | * @return $this |
144 | 144 | */ |
145 | - final public function setNotificationsEnabled (bool $flag) { |
|
145 | + final public function setNotificationsEnabled(bool $flag) { |
|
146 | 146 | return $this->_set('has_notifications_enabled', $flag); |
147 | 147 | } |
148 | 148 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param callable $cmp `fn( EnumOption $a, EnumOption $b ): int` |
151 | 151 | * @return $this |
152 | 152 | */ |
153 | - public function sortEnumOptions (callable $cmp) { |
|
153 | + public function sortEnumOptions(callable $cmp) { |
|
154 | 154 | if ($options = $this->getEnumOptions()) { |
155 | 155 | $prev = $options[0]; // first option on remote |
156 | 156 | usort($options, $cmp); |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * @param Workspace $workspace |
21 | 21 | * @return $this |
22 | 22 | */ |
23 | - final public function setWorkspace (Workspace $workspace) { |
|
23 | + final public function setWorkspace(Workspace $workspace) { |
|
24 | 24 | return $this->_set('workspace', $workspace); |
25 | 25 | } |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - final public function __toString (): string { |
|
41 | + final public function __toString(): string { |
|
42 | 42 | return "organization_exports/{$this->getGid()}"; |
43 | 43 | } |
44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @return string |
49 | 49 | */ |
50 | - final protected function _getDir (): string { |
|
50 | + final protected function _getDir(): string { |
|
51 | 51 | return "organization_exports"; |
52 | 52 | } |
53 | 53 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param Workspace $organization |
56 | 56 | * @return $this |
57 | 57 | */ |
58 | - public function create (Workspace $organization) { |
|
58 | + public function create(Workspace $organization) { |
|
59 | 59 | $this->_set('organization', $organization); |
60 | 60 | return $this->_create(); |
61 | 61 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - final public function isActive (): bool { |
|
68 | + final public function isActive(): bool { |
|
69 | 69 | return $this->getState() === self::STATE_ACTIVE; |
70 | 70 | } |
71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | - final public function isDone (): bool { |
|
77 | + final public function isDone(): bool { |
|
78 | 78 | return $this->isSuccessful() or $this->isFailed(); |
79 | 79 | } |
80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return bool |
85 | 85 | */ |
86 | - final public function isFailed (): bool { |
|
86 | + final public function isFailed(): bool { |
|
87 | 87 | return $this->getState() === self::STATE_FAIL; |
88 | 88 | } |
89 | 89 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return bool |
94 | 94 | */ |
95 | - final public function isQueued (): bool { |
|
95 | + final public function isQueued(): bool { |
|
96 | 96 | return $this->getState() === self::STATE_QUEUED; |
97 | 97 | } |
98 | 98 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool |
103 | 103 | */ |
104 | - final public function isSuccessful (): bool { |
|
104 | + final public function isSuccessful(): bool { |
|
105 | 105 | return $this->getState() === self::STATE_SUCCESS; |
106 | 106 | } |
107 | 107 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param callable $spinner `fn( OrganizationExport $this ): void` |
114 | 114 | * @return $this |
115 | 115 | */ |
116 | - public function wait (callable $spinner = null) { |
|
116 | + public function wait(callable $spinner = null) { |
|
117 | 117 | while (!$this->isDone()) { |
118 | 118 | if ($spinner) { |
119 | 119 | call_user_func($spinner, $this); |