@@ -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); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param int $limit 1-100 |
57 | 57 | * @return array|AbstractEntity[] |
58 | 58 | */ |
59 | - protected function find (string $class, string $text, int $limit = 20) { |
|
59 | + protected function find(string $class, string $text, int $limit = 20) { |
|
60 | 60 | return $this->_loadAll($class, "{$this}/typeahead", [ |
61 | 61 | 'resource_type' => $class::TYPE, |
62 | 62 | 'query' => $text, |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param int $limit 1-100 |
72 | 72 | * @return CustomField[] |
73 | 73 | */ |
74 | - public function findCustomFields (string $text, int $limit = 20) { |
|
74 | + public function findCustomFields(string $text, int $limit = 20) { |
|
75 | 75 | return $this->find(CustomField::class, $text, $limit); |
76 | 76 | } |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param int $limit 1-100 |
83 | 83 | * @return Portfolio[] |
84 | 84 | */ |
85 | - public function findPortfolios (string $text, int $limit = 20) { |
|
85 | + public function findPortfolios(string $text, int $limit = 20) { |
|
86 | 86 | return $this->find(Portfolio::class, $text, $limit); |
87 | 87 | } |
88 | 88 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param int $limit 1-100 |
94 | 94 | * @return Project[] |
95 | 95 | */ |
96 | - public function findProjects (string $text, int $limit = 20) { |
|
96 | + public function findProjects(string $text, int $limit = 20) { |
|
97 | 97 | return $this->find(Project::class, $text, $limit); |
98 | 98 | } |
99 | 99 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param int $limit 1-100 |
105 | 105 | * @return Tag[] |
106 | 106 | */ |
107 | - public function findTags (string $text, int $limit = 20) { |
|
107 | + public function findTags(string $text, int $limit = 20) { |
|
108 | 108 | return $this->find(Tag::class, $text, $limit); |
109 | 109 | } |
110 | 110 | |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * @param int $limit 1-100 |
116 | 116 | * @return Task[] |
117 | 117 | */ |
118 | - public function findTasks (string $text, int $limit = 20) { |
|
118 | + public function findTasks(string $text, int $limit = 20) { |
|
119 | 119 | return $this->find(Task::class, $text, $limit); |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @return CustomField[] |
124 | 124 | */ |
125 | - public function getCustomFields () { |
|
125 | + public function getCustomFields() { |
|
126 | 126 | return $this->_loadAll(CustomField::class, "{$this}/custom_fields"); |
127 | 127 | } |
128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return Portfolio[] |
135 | 135 | */ |
136 | - public function getPortfolios () { |
|
136 | + public function getPortfolios() { |
|
137 | 137 | return $this->_loadAll(Portfolio::class, "portfolios", [ |
138 | 138 | 'workspace' => $this->getGid(), |
139 | 139 | 'owner' => $this->api->getMe()->getGid() // the only allowed value, but still required. |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param array $filter |
147 | 147 | * @return Project[] |
148 | 148 | */ |
149 | - public function getProjects (array $filter = ['archived' => false]) { |
|
149 | + public function getProjects(array $filter = ['archived' => false]) { |
|
150 | 150 | $filter['workspace'] = $this->getGid(); |
151 | 151 | return $this->_loadAll(Project::class, 'projects', $filter); |
152 | 152 | } |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @return Tag[] |
156 | 156 | */ |
157 | - public function getTags () { |
|
157 | + public function getTags() { |
|
158 | 158 | return $this->_loadAll(Tag::class, 'tags', ['workspace' => $this->getGid()]); |
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
162 | 162 | * @return Team[] |
163 | 163 | */ |
164 | - public function getTeams () { |
|
164 | + public function getTeams() { |
|
165 | 165 | return $this->_loadAll(Team::class, "organizations/{$this->getGid()}/teams"); |
166 | 166 | } |
167 | 167 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param string $email |
170 | 170 | * @return null|User |
171 | 171 | */ |
172 | - public function getUserByEmail (string $email) { |
|
172 | + public function getUserByEmail(string $email) { |
|
173 | 173 | return $this->api->getCache()->get("users/{$email}", $this, function() use ($email) { |
174 | 174 | foreach ($this->getUsers() as $user) { |
175 | 175 | if ($user->getEmail() === $email) { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | /** |
184 | 184 | * @return User[] |
185 | 185 | */ |
186 | - public function getUsers () { |
|
186 | + public function getUsers() { |
|
187 | 187 | return $this->_loadAll(User::class, "{$this}/users"); |
188 | 188 | } |
189 | 189 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return ProjectWebhook[]|TaskWebhook[] |
194 | 194 | */ |
195 | - public function getWebhooks () { |
|
195 | + public function getWebhooks() { |
|
196 | 196 | /** @var array $all */ |
197 | 197 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
198 | 198 | return array_map(function(array $each) { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | /** |
210 | 210 | * @return bool |
211 | 211 | */ |
212 | - public function isOrganization (): bool { |
|
212 | + public function isOrganization(): bool { |
|
213 | 213 | return $this->_is('is_organization'); |
214 | 214 | } |
215 | 215 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return CustomField |
220 | 220 | */ |
221 | - public function newCustomField () { |
|
221 | + public function newCustomField() { |
|
222 | 222 | /** @var CustomField $field */ |
223 | 223 | $field = $this->_factory(CustomField::class); |
224 | 224 | return $field->setWorkspace($this); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return Portfolio |
231 | 231 | */ |
232 | - public function newPortfolio () { |
|
232 | + public function newPortfolio() { |
|
233 | 233 | /** @var Portfolio $portfolio */ |
234 | 234 | $portfolio = $this->_factory(Portfolio::class); |
235 | 235 | return $portfolio->setWorkspace($this); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return Project |
242 | 242 | */ |
243 | - public function newProject () { |
|
243 | + public function newProject() { |
|
244 | 244 | /** @var Project $project */ |
245 | 245 | $project = $this->_factory(Project::class); |
246 | 246 | return $project->setWorkspace($this); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return Tag |
253 | 253 | */ |
254 | - public function newTag () { |
|
254 | + public function newTag() { |
|
255 | 255 | /** @var Tag $tag */ |
256 | 256 | $tag = $this->_factory(Tag::class); |
257 | 257 | return $tag->setWorkspace($this); |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return Task |
264 | 264 | */ |
265 | - public function newTask () { |
|
265 | + public function newTask() { |
|
266 | 266 | /** @var Task $task */ |
267 | 267 | $task = $this->_factory(Task::class); |
268 | 268 | return $task->setWorkspace($this); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param callable $filter `fn( CustomField $field ): bool` |
273 | 273 | * @return CustomField[] |
274 | 274 | */ |
275 | - public function selectCustomFields (callable $filter) { |
|
275 | + public function selectCustomFields(callable $filter) { |
|
276 | 276 | return $this->_select($this->getCustomFields(), $filter); |
277 | 277 | } |
278 | 278 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param callable $filter `fn( Portfolio $portfolio ): bool` |
281 | 281 | * @return Portfolio[] |
282 | 282 | */ |
283 | - public function selectPortfolios (callable $filter) { |
|
283 | + public function selectPortfolios(callable $filter) { |
|
284 | 284 | return $this->_select($this->getPortfolios(), $filter); |
285 | 285 | } |
286 | 286 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param callable $filter `fn( Project $project ): bool` |
289 | 289 | * @return Project[] |
290 | 290 | */ |
291 | - public function selectProjects (callable $filter) { |
|
291 | + public function selectProjects(callable $filter) { |
|
292 | 292 | return $this->_select($this->getProjects([]), $filter); |
293 | 293 | } |
294 | 294 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @param callable $filter `fn( Tag $tag ): bool` |
297 | 297 | * @return Tag[] |
298 | 298 | */ |
299 | - public function selectTags (callable $filter) { |
|
299 | + public function selectTags(callable $filter) { |
|
300 | 300 | return $this->_select($this->getTags(), $filter); |
301 | 301 | } |
302 | 302 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param callable $filter `fn( Team $team ): bool` |
305 | 305 | * @return Team[] |
306 | 306 | */ |
307 | - public function selectTeams (callable $filter) { |
|
307 | + public function selectTeams(callable $filter) { |
|
308 | 308 | return $this->_select($this->getTeams(), $filter); |
309 | 309 | } |
310 | 310 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @param callable $filter |
313 | 313 | * @return User[] |
314 | 314 | */ |
315 | - public function selectUsers (callable $filter) { |
|
315 | + public function selectUsers(callable $filter) { |
|
316 | 316 | return $this->_select($this->getUsers(), $filter); |
317 | 317 | } |
318 | 318 | } |
319 | 319 | \ No newline at end of file |
@@ -33,25 +33,25 @@ |
||
33 | 33 | 'workspace' => Workspace::class |
34 | 34 | ]; |
35 | 35 | |
36 | - final public function __toString (): string { |
|
36 | + final public function __toString(): string { |
|
37 | 37 | return "tags/{$this->getGid()}"; |
38 | 38 | } |
39 | 39 | |
40 | - final protected function _getDir (): string { |
|
40 | + final protected function _getDir(): string { |
|
41 | 41 | return 'tags'; |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @return Traversable|Task[] |
46 | 46 | */ |
47 | - public function getIterator () { |
|
47 | + public function getIterator() { |
|
48 | 48 | return $this->_loadEach(Task::class, "{$this}/tasks"); |
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @return Task[] |
53 | 53 | */ |
54 | - public function getTasks () { |
|
54 | + public function getTasks() { |
|
55 | 55 | return iterator_to_array($this); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | \ No newline at end of file |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | 'organization' => Workspace::class |
25 | 25 | ]; |
26 | 26 | |
27 | - final public function __toString (): string { |
|
27 | + final public function __toString(): string { |
|
28 | 28 | return "teams/{$this->getGid()}"; |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param User $user |
33 | 33 | * @return $this |
34 | 34 | */ |
35 | - public function addUser (User $user) { |
|
35 | + public function addUser(User $user) { |
|
36 | 36 | $this->api->post("{$this}/addUser", ['user' => $user->getGid()]); |
37 | 37 | return $this; |
38 | 38 | } |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | * @param array $filter |
46 | 46 | * @return Project[] |
47 | 47 | */ |
48 | - public function getProjects (array $filter = ['archived' => false]) { |
|
48 | + public function getProjects(array $filter = ['archived' => false]) { |
|
49 | 49 | return $this->_loadAll(Project::class, "{$this}/projects", $filter); |
50 | 50 | } |
51 | 51 | |
52 | - public function getUrl (): string { |
|
52 | + public function getUrl(): string { |
|
53 | 53 | return "https://app.asana.com/0/{$this->getGid()}/overview"; |
54 | 54 | } |
55 | 55 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return User[] |
62 | 62 | */ |
63 | - public function getUsers () { |
|
63 | + public function getUsers() { |
|
64 | 64 | return $this->_loadAll(User::class, "{$this}/users"); |
65 | 65 | } |
66 | 66 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param User $user |
69 | 69 | * @return $this |
70 | 70 | */ |
71 | - public function removeUser (User $user) { |
|
71 | + public function removeUser(User $user) { |
|
72 | 72 | $this->api->post("{$this}/removeUser", ['user' => $user->getGid()]); |
73 | 73 | return $this; |
74 | 74 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param Api|Data $caller |
49 | 49 | * @param array $data |
50 | 50 | */ |
51 | - public function __construct ($caller, array $data = []) { |
|
51 | + public function __construct($caller, array $data = []) { |
|
52 | 52 | $this->api = $caller instanceof self ? $caller->api : $caller; |
53 | 53 | $this->_setData($data); |
54 | 54 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @param array $args |
65 | 65 | * @return mixed |
66 | 66 | */ |
67 | - public function __call (string $method, array $args) { |
|
67 | + public function __call(string $method, array $args) { |
|
68 | 68 | static $cache = []; |
69 | - if (!$call =& $cache[$method]) { |
|
69 | + if (!$call = & $cache[$method]) { |
|
70 | 70 | preg_match('/^(get|has|is|select|set)(.+)$/', $method, $call); |
71 | 71 | $call[1] = '_' . $call[1]; |
72 | 72 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | return $this->{$call[1]}($call[2], ...$args); |
77 | 77 | } |
78 | 78 | |
79 | - public function __debugInfo (): array { |
|
79 | + public function __debugInfo(): array { |
|
80 | 80 | return $this->data; |
81 | 81 | } |
82 | 82 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param $field |
87 | 87 | * @return null|Data|mixed |
88 | 88 | */ |
89 | - final public function __get ($field) { |
|
89 | + final public function __get($field) { |
|
90 | 90 | return $this->_get($field); |
91 | 91 | } |
92 | 92 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param $field |
99 | 99 | * @return bool |
100 | 100 | */ |
101 | - final public function __isset ($field) { |
|
101 | + final public function __isset($field) { |
|
102 | 102 | return true; |
103 | 103 | } |
104 | 104 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param array $data |
110 | 110 | * @return mixed|Data|AbstractEntity |
111 | 111 | */ |
112 | - final protected function _factory (string $class, array $data = []) { |
|
112 | + final protected function _factory(string $class, array $data = []) { |
|
113 | 113 | return $this->api->factory($class, $this, $data); |
114 | 114 | } |
115 | 115 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param string $field |
122 | 122 | * @return mixed |
123 | 123 | */ |
124 | - protected function _get (string $field) { |
|
124 | + protected function _get(string $field) { |
|
125 | 125 | return $this->data[$field] ?? null; |
126 | 126 | } |
127 | 127 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param string $field |
137 | 137 | * @return bool |
138 | 138 | */ |
139 | - protected function _has (string $field): bool { |
|
139 | + protected function _has(string $field): bool { |
|
140 | 140 | $value = $this->_get($field); |
141 | 141 | if (isset($value)) { |
142 | 142 | if (is_countable($value)) { |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string $field |
160 | 160 | * @return bool |
161 | 161 | */ |
162 | - protected function _is (string $field): bool { |
|
162 | + protected function _is(string $field): bool { |
|
163 | 163 | return (bool)$this->_get($field); |
164 | 164 | } |
165 | 165 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param array $query |
174 | 174 | * @return null|mixed|AbstractEntity |
175 | 175 | */ |
176 | - final protected function _load (string $class, string $path, array $query = []) { |
|
176 | + final protected function _load(string $class, string $path, array $query = []) { |
|
177 | 177 | return $this->api->load($class, $this, $path, $query); |
178 | 178 | } |
179 | 179 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @param int $pages |
189 | 189 | * @return array|AbstractEntity[] |
190 | 190 | */ |
191 | - final protected function _loadAll (string $class, string $path, array $query = [], int $pages = 0) { |
|
191 | + final protected function _loadAll(string $class, string $path, array $query = [], int $pages = 0) { |
|
192 | 192 | return $this->api->loadAll($class, $this, $path, $query, $pages); |
193 | 193 | } |
194 | 194 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param int $pages |
204 | 204 | * @return Traversable|AbstractEntity[] |
205 | 205 | */ |
206 | - final protected function _loadEach (string $class, string $path, array $query = [], int $pages = 0) { |
|
206 | + final protected function _loadEach(string $class, string $path, array $query = [], int $pages = 0) { |
|
207 | 207 | return $this->api->loadEach($class, $this, $path, $query, $pages); |
208 | 208 | } |
209 | 209 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param callable $filter `fn( Data $object ): bool` |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - protected function _select ($subject, callable $filter) { |
|
221 | + protected function _select($subject, callable $filter) { |
|
222 | 222 | if (!is_iterable($subject)) { |
223 | 223 | $subject = $this->_get($subject) ?? []; |
224 | 224 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param mixed $value |
241 | 241 | * @return $this |
242 | 242 | */ |
243 | - protected function _set (string $field, $value) { |
|
243 | + protected function _set(string $field, $value) { |
|
244 | 244 | $this->data[$field] = $value; |
245 | 245 | $this->diff[$field] = true; |
246 | 246 | return $this; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @param array $data |
253 | 253 | */ |
254 | - protected function _setData (array $data): void { |
|
254 | + protected function _setData(array $data): void { |
|
255 | 255 | $this->data = $this->diff = []; |
256 | 256 | foreach ($data as $field => $value) { |
257 | 257 | $this->_setMapped($field, $value); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @param string $field |
265 | 265 | * @param mixed $value |
266 | 266 | */ |
267 | - protected function _setMapped (string $field, $value): void { |
|
267 | + protected function _setMapped(string $field, $value): void { |
|
268 | 268 | unset($this->diff[$field]); |
269 | 269 | |
270 | 270 | // use value as-is? |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return array |
312 | 312 | */ |
313 | - public function getDiff (): array { |
|
313 | + public function getDiff(): array { |
|
314 | 314 | $convert = function($each) use (&$convert) { |
315 | 315 | // convert existing entities to gids |
316 | 316 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @param string null $field |
337 | 337 | * @return bool |
338 | 338 | */ |
339 | - final public function isDiff (string $field = null): bool { |
|
339 | + final public function isDiff(string $field = null): bool { |
|
340 | 340 | if ($field) { |
341 | 341 | return isset($this->diff[$field]); |
342 | 342 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * @see toArray() |
348 | 348 | * @return array |
349 | 349 | */ |
350 | - public function jsonSerialize (): array { |
|
350 | + public function jsonSerialize(): array { |
|
351 | 351 | $data = $this->toArray(); |
352 | 352 | ksort($data); |
353 | 353 | return $data; |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public function serialize (): string { |
|
362 | - return json_encode($this, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
361 | + public function serialize(): string { |
|
362 | + return json_encode($this, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @return array |
369 | 369 | */ |
370 | - public function toArray (): array { |
|
370 | + public function toArray(): array { |
|
371 | 371 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
372 | 372 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
373 | 373 | return $each->getGid(); |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * |
388 | 388 | * @param $serialized |
389 | 389 | */ |
390 | - public function unserialize ($serialized): void { |
|
390 | + public function unserialize($serialized): void { |
|
391 | 391 | $this->api = Api::getDefault(); |
392 | 392 | $data = json_decode($serialized, true); |
393 | 393 | $this->_setData($data); |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | 'workspace' => Workspace::class |
31 | 31 | ]; |
32 | 32 | |
33 | - final public function __toString (): string { |
|
33 | + final public function __toString(): string { |
|
34 | 34 | return "user_task_lists/{$this->getGid()}"; |
35 | 35 | } |
36 | 36 | |
37 | - public function getCacheKeys () { |
|
37 | + public function getCacheKeys() { |
|
38 | 38 | $keys = parent::getCacheKeys(); |
39 | 39 | |
40 | 40 | /** @see User::getTaskList() */ |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * @return Task[] |
48 | 48 | */ |
49 | - public function getIncompleteTasks () { |
|
49 | + public function getIncompleteTasks() { |
|
50 | 50 | return $this->getTasks(['completed_since' => 'now']); |
51 | 51 | } |
52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param array $filter |
55 | 55 | * @return Traversable|Task[] |
56 | 56 | */ |
57 | - public function getIterator (array $filter = []) { |
|
57 | + public function getIterator(array $filter = []) { |
|
58 | 58 | return $this->_loadEach(Task::class, "{$this}/tasks"); |
59 | 59 | } |
60 | 60 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param array $filter |
67 | 67 | * @return Task[] |
68 | 68 | */ |
69 | - public function getTasks (array $filter = []) { |
|
69 | + public function getTasks(array $filter = []) { |
|
70 | 70 | return iterator_to_array($this->getIterator($filter)); |
71 | 71 | } |
72 | 72 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param array $apiFilter Given to the API to reduce network load. |
76 | 76 | * @return Task[] |
77 | 77 | */ |
78 | - public function selectTasks (callable $filter, array $apiFilter) { |
|
78 | + public function selectTasks(callable $filter, array $apiFilter) { |
|
79 | 79 | return $this->_select($this->getIterator($apiFilter), $filter); |
80 | 80 | } |
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | 'workspace' => Workspace::class |
53 | 53 | ]; |
54 | 54 | |
55 | - final public function __toString (): string { |
|
55 | + final public function __toString(): string { |
|
56 | 56 | return "portfolios/{$this->getGid()}"; |
57 | 57 | } |
58 | 58 | |
59 | - final protected function _getDir (): string { |
|
59 | + final protected function _getDir(): string { |
|
60 | 60 | return 'portfolios'; |
61 | 61 | } |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param Project $item |
66 | 66 | * @return $this |
67 | 67 | */ |
68 | - public function addItem (Project $item) { |
|
68 | + public function addItem(Project $item) { |
|
69 | 69 | $this->api->post("{$this}/addItem", ['item' => $item->getGid()]); |
70 | 70 | return $this; |
71 | 71 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param User $user |
75 | 75 | * @return $this |
76 | 76 | */ |
77 | - public function addMember (User $user) { |
|
77 | + public function addMember(User $user) { |
|
78 | 78 | return $this->addMembers([$user]); |
79 | 79 | } |
80 | 80 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param User[] $users |
83 | 83 | * @return $this |
84 | 84 | */ |
85 | - public function addMembers (array $users) { |
|
85 | + public function addMembers(array $users) { |
|
86 | 86 | return $this->_addWithPost("{$this}/addMembers", [ |
87 | 87 | 'members' => array_column($users, 'gid') |
88 | 88 | ], 'members', $users); |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | * @depends after-create |
93 | 93 | * @return Project[] |
94 | 94 | */ |
95 | - public function getItems () { |
|
95 | + public function getItems() { |
|
96 | 96 | return iterator_to_array($this); |
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * @return Traversable|Project[] |
101 | 101 | */ |
102 | - public function getIterator () { |
|
102 | + public function getIterator() { |
|
103 | 103 | return $this->_loadEach(Project::class, "{$this}/items"); |
104 | 104 | } |
105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param Project $item |
109 | 109 | * @return $this |
110 | 110 | */ |
111 | - public function removeItem (Project $item) { |
|
111 | + public function removeItem(Project $item) { |
|
112 | 112 | $this->api->post("{$this}/removeItem", ['item' => $item->getGid()]); |
113 | 113 | return $this; |
114 | 114 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param User $user |
118 | 118 | * @return $this |
119 | 119 | */ |
120 | - public function removeMember (User $user) { |
|
120 | + public function removeMember(User $user) { |
|
121 | 121 | return $this->removeMembers([$user]); |
122 | 122 | } |
123 | 123 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param User[] $users |
126 | 126 | * @return $this |
127 | 127 | */ |
128 | - public function removeMembers (array $users) { |
|
128 | + public function removeMembers(array $users) { |
|
129 | 129 | return $this->_removeWithPost("{$this}/removeMembers", [ |
130 | 130 | 'members' => array_column($users, 'gid') |
131 | 131 | ], 'members', $users); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param callable $filter `fn( Project $project ): bool` |
136 | 136 | * @return Project[] |
137 | 137 | */ |
138 | - public function selectItems (callable $filter) { |
|
138 | + public function selectItems(callable $filter) { |
|
139 | 139 | return $this->_select($this, $filter); |
140 | 140 | } |
141 | 141 | } |
142 | 142 | \ No newline at end of file |
@@ -54,25 +54,25 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @return Cache |
56 | 56 | */ |
57 | - public static function getCache () { |
|
57 | + public static function getCache() { |
|
58 | 58 | return static::$cache ?? static::$cache = new Cache(); |
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @return Api |
63 | 63 | */ |
64 | - public static function getDefault () { |
|
64 | + public static function getDefault() { |
|
65 | 65 | return self::$default; |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return LoggerInterface |
70 | 70 | */ |
71 | - public static function getLogger () { |
|
71 | + public static function getLogger() { |
|
72 | 72 | return static::$logger |
73 | 73 | ?? static::$logger = new class implements LoggerInterface { |
74 | 74 | |
75 | - public function log (string $message, string $path, array $data = null): void { |
|
75 | + public function log(string $message, string $path, array $data = null): void { |
|
76 | 76 | // stub |
77 | 77 | } |
78 | 78 | |
@@ -82,28 +82,28 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * @param Cache $cache |
84 | 84 | */ |
85 | - public static function setCache (Cache $cache) { |
|
85 | + public static function setCache(Cache $cache) { |
|
86 | 86 | static::$cache = $cache; |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | 90 | * @param Api $default |
91 | 91 | */ |
92 | - public static function setDefault (Api $default) { |
|
92 | + public static function setDefault(Api $default) { |
|
93 | 93 | self::$default = $default; |
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
97 | 97 | * @param LoggerInterface $logger |
98 | 98 | */ |
99 | - public static function setLogger (LoggerInterface $logger) { |
|
99 | + public static function setLogger(LoggerInterface $logger) { |
|
100 | 100 | static::$logger = $logger; |
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @param string $token |
105 | 105 | */ |
106 | - public function __construct (string $token) { |
|
106 | + public function __construct(string $token) { |
|
107 | 107 | $this->token = $token; |
108 | 108 | if (!static::$default) { |
109 | 109 | static::$default = $this; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return null|array |
120 | 120 | * @internal |
121 | 121 | */ |
122 | - protected function _exec (string $method, string $path, array $opts = []) { |
|
122 | + protected function _exec(string $method, string $path, array $opts = []) { |
|
123 | 123 | static::getLogger()->log($method, $path, $opts); |
124 | 124 | /** @var resource $ch */ |
125 | 125 | $ch = curl_init(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return string |
169 | 169 | * @internal |
170 | 170 | */ |
171 | - protected function _getPath (string $path, array $query): string { |
|
171 | + protected function _getPath(string $path, array $query): string { |
|
172 | 172 | return $query ? $path . '?' . http_build_query($query) : $path; |
173 | 173 | } |
174 | 174 | |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | * @return null|array |
178 | 178 | * @internal |
179 | 179 | */ |
180 | - protected function _jsonDecode (string $json) { |
|
181 | - return json_decode($json, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
180 | + protected function _jsonDecode(string $json) { |
|
181 | + return json_decode($json, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @return string |
187 | 187 | * @internal |
188 | 188 | */ |
189 | - protected function _jsonEncode (array $data): string { |
|
190 | - return json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
|
189 | + protected function _jsonEncode(array $data): string { |
|
190 | + return json_encode($data, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @param string $path |
197 | 197 | */ |
198 | - public function delete (string $path): void { |
|
198 | + public function delete(string $path): void { |
|
199 | 199 | $this->_exec('DELETE', $path); |
200 | 200 | } |
201 | 201 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param array $data |
210 | 210 | * @return mixed|Data|AbstractEntity |
211 | 211 | */ |
212 | - public function factory (string $class, $caller, array $data = []) { |
|
212 | + public function factory(string $class, $caller, array $data = []) { |
|
213 | 213 | return new $class($caller, $data); |
214 | 214 | } |
215 | 215 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @param array $options |
222 | 222 | * @return null|array |
223 | 223 | */ |
224 | - public function get (string $path, array $query = [], array $options = []) { |
|
224 | + public function get(string $path, array $query = [], array $options = []) { |
|
225 | 225 | foreach ($options as $name => $value) { |
226 | 226 | $query["opt_{$name}"] = $value; |
227 | 227 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param string $gid |
236 | 236 | * @return null|Attachment |
237 | 237 | */ |
238 | - public function getAttachment (string $gid) { |
|
238 | + public function getAttachment(string $gid) { |
|
239 | 239 | return $this->load(Attachment::class, $this, "attachments/{$gid}"); |
240 | 240 | } |
241 | 241 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param string $gid |
246 | 246 | * @return null|CustomField |
247 | 247 | */ |
248 | - public function getCustomField (string $gid) { |
|
248 | + public function getCustomField(string $gid) { |
|
249 | 249 | return $this->load(CustomField::class, $this, "custom_fields/{$gid}"); |
250 | 250 | } |
251 | 251 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @return Workspace |
257 | 257 | */ |
258 | - public function getDefaultWorkspace () { |
|
258 | + public function getDefaultWorkspace() { |
|
259 | 259 | return $this->getMe()->getDefaultWorkspace(); |
260 | 260 | } |
261 | 261 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return User |
266 | 266 | */ |
267 | - public function getMe () { |
|
267 | + public function getMe() { |
|
268 | 268 | return $this->getUser('me'); |
269 | 269 | } |
270 | 270 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param string $gid |
275 | 275 | * @return null|Portfolio |
276 | 276 | */ |
277 | - public function getPortfolio (string $gid) { |
|
277 | + public function getPortfolio(string $gid) { |
|
278 | 278 | return $this->load(Portfolio::class, $this, "portfolios/{$gid}"); |
279 | 279 | } |
280 | 280 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @param string $gid |
285 | 285 | * @return null|Project |
286 | 286 | */ |
287 | - public function getProject (string $gid) { |
|
287 | + public function getProject(string $gid) { |
|
288 | 288 | return $this->load(Project::class, $this, "projects/{$gid}"); |
289 | 289 | } |
290 | 290 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * @param string $gid |
295 | 295 | * @return null|Section |
296 | 296 | */ |
297 | - public function getSection (string $gid) { |
|
297 | + public function getSection(string $gid) { |
|
298 | 298 | return $this->load(Section::class, $this, "sections/{$gid}"); |
299 | 299 | } |
300 | 300 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param string $gid |
305 | 305 | * @return null|Story |
306 | 306 | */ |
307 | - public function getStory (string $gid) { |
|
307 | + public function getStory(string $gid) { |
|
308 | 308 | return $this->load(Story::class, $this, "stories/{$gid}"); |
309 | 309 | } |
310 | 310 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @param string $gid |
315 | 315 | * @return null|Tag |
316 | 316 | */ |
317 | - public function getTag (string $gid) { |
|
317 | + public function getTag(string $gid) { |
|
318 | 318 | return $this->load(Tag::class, $this, "tags/{$gid}"); |
319 | 319 | } |
320 | 320 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @param string $gid |
325 | 325 | * @return null|Task |
326 | 326 | */ |
327 | - public function getTask (string $gid) { |
|
327 | + public function getTask(string $gid) { |
|
328 | 328 | return $this->load(Task::class, $this, "tasks/{$gid}"); |
329 | 329 | } |
330 | 330 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param string $gid |
335 | 335 | * @return null|TaskList |
336 | 336 | */ |
337 | - public function getTaskList (string $gid) { |
|
337 | + public function getTaskList(string $gid) { |
|
338 | 338 | return $this->load(TaskList::class, $this, "user_task_lists/{$gid}"); |
339 | 339 | } |
340 | 340 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @param string $gid |
345 | 345 | * @return null|Team |
346 | 346 | */ |
347 | - public function getTeam (string $gid) { |
|
347 | + public function getTeam(string $gid) { |
|
348 | 348 | return $this->load(Team::class, $this, "teams/{$gid}"); |
349 | 349 | } |
350 | 350 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @param string $gid |
355 | 355 | * @return null|User |
356 | 356 | */ |
357 | - public function getUser (string $gid) { |
|
357 | + public function getUser(string $gid) { |
|
358 | 358 | return $this->load(User::class, $this, "users/{$gid}"); |
359 | 359 | } |
360 | 360 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @param array $data |
367 | 367 | * @return ProjectEvent|TaskEvent|StoryEvent |
368 | 368 | */ |
369 | - public function getWebhookEvent (array $data) { |
|
369 | + public function getWebhookEvent(array $data) { |
|
370 | 370 | static $classes = [ |
371 | 371 | Project::TYPE => ProjectEvent::class, |
372 | 372 | Task::TYPE => TaskEvent::class, |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * @param string $gid |
382 | 382 | * @return null|Workspace |
383 | 383 | */ |
384 | - public function getWorkspace (string $gid) { |
|
384 | + public function getWorkspace(string $gid) { |
|
385 | 385 | return $this->load(Workspace::class, $this, "workspaces/{$gid}"); |
386 | 386 | } |
387 | 387 | |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @param string $name |
392 | 392 | * @return null|Workspace |
393 | 393 | */ |
394 | - public function getWorkspaceByName (string $name) { |
|
394 | + public function getWorkspaceByName(string $name) { |
|
395 | 395 | foreach ($this->getWorkspaces() as $workspace) { |
396 | 396 | if ($workspace->getName() === $name) { |
397 | 397 | return $workspace; |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return Workspace[] |
407 | 407 | */ |
408 | - public function getWorkspaces () { |
|
408 | + public function getWorkspaces() { |
|
409 | 409 | return $this->getMe()->getWorkspaces(); |
410 | 410 | } |
411 | 411 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | * @param array $query |
421 | 421 | * @return null|mixed|AbstractEntity |
422 | 422 | */ |
423 | - public function load (string $class, $caller, string $path, array $query = []) { |
|
423 | + public function load(string $class, $caller, string $path, array $query = []) { |
|
424 | 424 | $key = $this->_getPath($path, $query); |
425 | 425 | return $this->getCache()->get($key, $caller, function($caller) use ($class, $path, $query) { |
426 | 426 | $data = $this->get($path, $query, ['expand' => 'this']); |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * @param int $pages |
439 | 439 | * @return array|AbstractEntity[] |
440 | 440 | */ |
441 | - public function loadAll (string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
441 | + public function loadAll(string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
442 | 442 | return iterator_to_array($this->loadEach(...func_get_args())); |
443 | 443 | } |
444 | 444 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * @param int $pages If positive, stops after this many pages have been fetched. |
455 | 455 | * @return Generator|AbstractEntity[] |
456 | 456 | */ |
457 | - public function loadEach (string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
457 | + public function loadEach(string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
458 | 458 | $query['opt_expand'] = 'this'; |
459 | 459 | $query += ['limit' => 100]; |
460 | 460 | $path = $this->_getPath($path, $query); |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @param array $options |
479 | 479 | * @return null|array |
480 | 480 | */ |
481 | - public function post (string $path, array $data = [], array $options = []) { |
|
481 | + public function post(string $path, array $data = [], array $options = []) { |
|
482 | 482 | $response = $this->_exec('POST', $path, [ |
483 | 483 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
484 | 484 | CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data]) |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @param array $options |
495 | 495 | * @return null|array |
496 | 496 | */ |
497 | - public function put (string $path, array $data = [], array $options = []) { |
|
497 | + public function put(string $path, array $data = [], array $options = []) { |
|
498 | 498 | $response = $this->_exec('PUT', $path, [ |
499 | 499 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
500 | 500 | CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data]) |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | * @param null|string $token |
514 | 514 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
515 | 515 | */ |
516 | - public function sync ($entity, ?string &$token) { |
|
516 | + public function sync($entity, ?string &$token) { |
|
517 | 517 | try { |
518 | 518 | $response = $this->_exec('GET', $this->_getPath('events', [ |
519 | 519 | 'resource' => $entity->getGid(), |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | * @param string $file |
549 | 549 | * @return null|array |
550 | 550 | */ |
551 | - public function upload (string $path, string $file) { |
|
551 | + public function upload(string $path, string $file) { |
|
552 | 552 | $response = $this->_exec('POST', $path, [ |
553 | 553 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
554 | 554 | ]); |
@@ -98,15 +98,15 @@ discard block |
||
98 | 98 | 'memberships' => 'memberships.(project|section)' |
99 | 99 | ]; |
100 | 100 | |
101 | - final public function __toString (): string { |
|
101 | + final public function __toString(): string { |
|
102 | 102 | return "tasks/{$this->getGid()}"; |
103 | 103 | } |
104 | 104 | |
105 | - final protected function _getDir (): string { |
|
105 | + final protected function _getDir(): string { |
|
106 | 106 | return 'tasks'; |
107 | 107 | } |
108 | 108 | |
109 | - protected function _save (string $dir = null) { |
|
109 | + protected function _save(string $dir = null) { |
|
110 | 110 | parent::_save($dir); |
111 | 111 | // use isset() to avoid has() fetch. |
112 | 112 | if (isset($this->data['custom_fields'])) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | return $this; |
119 | 119 | } |
120 | 120 | |
121 | - protected function _setData (array $data): void { |
|
121 | + protected function _setData(array $data): void { |
|
122 | 122 | // hearts were deprecated for likes |
123 | 123 | unset($data['hearted'], $data['hearts']); |
124 | 124 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param string $file |
136 | 136 | * @return Attachment |
137 | 137 | */ |
138 | - public function addAttachment (string $file) { |
|
138 | + public function addAttachment(string $file) { |
|
139 | 139 | /** @var Attachment $attachment */ |
140 | 140 | $attachment = $this->_factory(Attachment::class, ['parent' => $this]); |
141 | 141 | return $attachment->upload($file); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param string $text |
148 | 148 | * @return Story |
149 | 149 | */ |
150 | - public function addComment (string $text) { |
|
150 | + public function addComment(string $text) { |
|
151 | 151 | return $this->newComment()->setText($text)->create(); |
152 | 152 | } |
153 | 153 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @param Task[] $tasks |
159 | 159 | * @return $this |
160 | 160 | */ |
161 | - public function addDependencies (array $tasks) { |
|
161 | + public function addDependencies(array $tasks) { |
|
162 | 162 | $this->api->post("{$this}/addDependencies", ['dependents' => array_column($tasks, 'gid')]); |
163 | 163 | return $this; |
164 | 164 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param Task $task |
171 | 171 | * @return $this |
172 | 172 | */ |
173 | - public function addDependency (Task $task) { |
|
173 | + public function addDependency(Task $task) { |
|
174 | 174 | return $this->addDependencies([$task]); |
175 | 175 | } |
176 | 176 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param Task $task |
182 | 182 | * @return $this |
183 | 183 | */ |
184 | - public function addDependent (Task $task) { |
|
184 | + public function addDependent(Task $task) { |
|
185 | 185 | return $this->addDependents([$task]); |
186 | 186 | } |
187 | 187 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param Task[] $tasks |
193 | 193 | * @return $this |
194 | 194 | */ |
195 | - public function addDependents (array $tasks) { |
|
195 | + public function addDependents(array $tasks) { |
|
196 | 196 | $this->api->post("{$this}/addDependents", ['dependents' => array_column($tasks, 'gid')]); |
197 | 197 | return $this; |
198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param User $user |
204 | 204 | * @return $this |
205 | 205 | */ |
206 | - public function addFollower (User $user) { |
|
206 | + public function addFollower(User $user) { |
|
207 | 207 | return $this->addFollowers([$user]); |
208 | 208 | } |
209 | 209 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param User[] $users |
216 | 216 | * @return $this |
217 | 217 | */ |
218 | - public function addFollowers (array $users) { |
|
218 | + public function addFollowers(array $users) { |
|
219 | 219 | return $this->_addWithPost("{$this}/addFollowers", [ |
220 | 220 | 'followers' => array_column($users, 'gid') |
221 | 221 | ], 'followers', $users); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @param Tag $tag |
230 | 230 | * @return $this |
231 | 231 | */ |
232 | - public function addTag (Tag $tag) { |
|
232 | + public function addTag(Tag $tag) { |
|
233 | 233 | return $this->_addWithPost("{$this}/addTag", [ |
234 | 234 | 'tag' => $tag->getGid() |
235 | 235 | ], 'tags', [$tag]); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param Section|null $section |
245 | 245 | * @return $this |
246 | 246 | */ |
247 | - public function addToProject (Project $project, Section $section = null) { |
|
247 | + public function addToProject(Project $project, Section $section = null) { |
|
248 | 248 | /** @var Membership $membership */ |
249 | 249 | $membership = $this->_factory(Membership::class) |
250 | 250 | ->_set('project', $project) |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param string $target |
260 | 260 | * @return TaskWebhook |
261 | 261 | */ |
262 | - public function addWebhook (string $target) { |
|
262 | + public function addWebhook(string $target) { |
|
263 | 263 | /** @var TaskWebhook $webhook */ |
264 | 264 | $webhook = $this->_factory(TaskWebhook::class); |
265 | 265 | return $webhook->create($this, $target); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @param string[] $include |
276 | 276 | * @return Job |
277 | 277 | */ |
278 | - public function duplicate (string $name, array $include) { |
|
278 | + public function duplicate(string $name, array $include) { |
|
279 | 279 | /** @var array $remote */ |
280 | 280 | $remote = $this->api->post("{$this}/duplicate", [ |
281 | 281 | 'name' => $name, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @depends after-create |
291 | 291 | * @return Attachment[] |
292 | 292 | */ |
293 | - public function getAttachments () { |
|
293 | + public function getAttachments() { |
|
294 | 294 | return $this->_loadAll(Attachment::class, "{$this}/attachments"); |
295 | 295 | } |
296 | 296 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @depends after-create |
301 | 301 | * @return Story[] |
302 | 302 | */ |
303 | - public function getComments () { |
|
303 | + public function getComments() { |
|
304 | 304 | return $this->selectStories(function(Story $story) { |
305 | 305 | return $story->isComment(); |
306 | 306 | }); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @depends after-create |
313 | 313 | * @return Task[] |
314 | 314 | */ |
315 | - public function getDependencies () { |
|
315 | + public function getDependencies() { |
|
316 | 316 | return $this->_loadAll(self::class, "{$this}/dependencies"); |
317 | 317 | } |
318 | 318 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @depends after-create |
323 | 323 | * @return Task[] |
324 | 324 | */ |
325 | - public function getDependents () { |
|
325 | + public function getDependents() { |
|
326 | 326 | return $this->_loadAll(self::class, "{$this}/dependents"); |
327 | 327 | } |
328 | 328 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @param null|string $token |
334 | 334 | * @return TaskEvent[]|StoryEvent[] |
335 | 335 | */ |
336 | - public function getEvents (&$token) { |
|
336 | + public function getEvents(&$token) { |
|
337 | 337 | return $this->api->sync($this, $token); |
338 | 338 | } |
339 | 339 | |
@@ -345,14 +345,14 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return External |
347 | 347 | */ |
348 | - public function getExternal () { |
|
348 | + public function getExternal() { |
|
349 | 349 | return $this->_get('external') ?? $this->data['external'] = $this->_factory(External::class); |
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
353 | 353 | * @return Project[] |
354 | 354 | */ |
355 | - public function getProjects () { |
|
355 | + public function getProjects() { |
|
356 | 356 | return array_map(function(Membership $membership) { |
357 | 357 | return $membership->getProject(); |
358 | 358 | }, $this->getMemberships()); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @depends after-create |
365 | 365 | * @return Story[] |
366 | 366 | */ |
367 | - public function getStories () { |
|
367 | + public function getStories() { |
|
368 | 368 | return $this->_loadAll(Story::class, "{$this}/stories"); |
369 | 369 | } |
370 | 370 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @depends after-create |
375 | 375 | * @return Task[] |
376 | 376 | */ |
377 | - public function getSubTasks () { |
|
377 | + public function getSubTasks() { |
|
378 | 378 | return $this->_loadAll(self::class, "{$this}/subtasks"); |
379 | 379 | } |
380 | 380 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @depends after-create |
385 | 385 | * @return string |
386 | 386 | */ |
387 | - public function getUrl (): string { |
|
387 | + public function getUrl(): string { |
|
388 | 388 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
389 | 389 | } |
390 | 390 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * @depends after-create |
395 | 395 | * @return TaskWebhook[] |
396 | 396 | */ |
397 | - public function getWebhooks () { |
|
397 | + public function getWebhooks() { |
|
398 | 398 | return $this->_loadAll(TaskWebhook::class, 'webhooks', [ |
399 | 399 | 'workspace' => $this->getWorkspace()->getGid(), |
400 | 400 | 'resource' => $this->getGid() |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | /** |
405 | 405 | * @return bool |
406 | 406 | */ |
407 | - public function isRenderedAsSeparator (): bool { |
|
407 | + public function isRenderedAsSeparator(): bool { |
|
408 | 408 | return $this->_is('is_rendered_as_separator'); |
409 | 409 | } |
410 | 410 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * @depends after-create |
415 | 415 | * @return Story |
416 | 416 | */ |
417 | - public function newComment () { |
|
417 | + public function newComment() { |
|
418 | 418 | return $this->_factory(Story::class, [ |
419 | 419 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED, |
420 | 420 | 'target' => $this |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * @depends after-create |
428 | 428 | * @return Task |
429 | 429 | */ |
430 | - public function newSubTask () { |
|
430 | + public function newSubTask() { |
|
431 | 431 | /** @var Task $sub */ |
432 | 432 | $sub = $this->_factory(self::class); |
433 | 433 | return $sub->setParent($this); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @param Task[] $tasks |
441 | 441 | * @return $this |
442 | 442 | */ |
443 | - public function removeDependencies (array $tasks) { |
|
443 | + public function removeDependencies(array $tasks) { |
|
444 | 444 | $this->api->post("{$this}/removeDependencies", ['dependencies' => array_column($tasks, 'gid')]); |
445 | 445 | return $this; |
446 | 446 | } |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | * @param Task $task |
453 | 453 | * @return $this |
454 | 454 | */ |
455 | - public function removeDependency (Task $task) { |
|
455 | + public function removeDependency(Task $task) { |
|
456 | 456 | return $this->removeDependencies([$task]); |
457 | 457 | } |
458 | 458 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * @param Task $task |
464 | 464 | * @return $this |
465 | 465 | */ |
466 | - public function removeDependent (Task $task) { |
|
466 | + public function removeDependent(Task $task) { |
|
467 | 467 | return $this->removeDependents([$task]); |
468 | 468 | } |
469 | 469 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | * @param Task[] $tasks |
475 | 475 | * @return $this |
476 | 476 | */ |
477 | - public function removeDependents (array $tasks) { |
|
477 | + public function removeDependents(array $tasks) { |
|
478 | 478 | $this->api->post("{$this}/removeDependents", ['dependents' => array_column($tasks, 'gid')]); |
479 | 479 | return $this; |
480 | 480 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * @param User $user |
486 | 486 | * @return $this |
487 | 487 | */ |
488 | - public function removeFollower (User $user) { |
|
488 | + public function removeFollower(User $user) { |
|
489 | 489 | return $this->removeFollowers([$user]); |
490 | 490 | } |
491 | 491 | |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | * @param User[] $users |
498 | 498 | * @return $this |
499 | 499 | */ |
500 | - public function removeFollowers (array $users) { |
|
500 | + public function removeFollowers(array $users) { |
|
501 | 501 | return $this->_removeWithPost("{$this}/removeFollowers", [ |
502 | 502 | 'followers' => array_column($users, 'gid') |
503 | 503 | ], 'followers', $users); |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * @param Project $project |
512 | 512 | * @return $this |
513 | 513 | */ |
514 | - public function removeFromProject (Project $project) { |
|
514 | + public function removeFromProject(Project $project) { |
|
515 | 515 | return $this->_removeWithPost("{$this}/removeProject", [ |
516 | 516 | 'project' => $project->getGid() |
517 | 517 | ], 'memberships', function(Membership $membership) use ($project) { |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * @param Tag $tag |
528 | 528 | * @return $this |
529 | 529 | */ |
530 | - public function removeTag (Tag $tag) { |
|
530 | + public function removeTag(Tag $tag) { |
|
531 | 531 | return $this->_removeWithPost("{$this}/removeTag", [ |
532 | 532 | 'tag' => $tag->getGid() |
533 | 533 | ], 'tags', [$tag]); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * @param callable $filter `fn( Attachment $attachment): bool` |
538 | 538 | * @return Attachment[] |
539 | 539 | */ |
540 | - public function selectAttachments (callable $filter) { |
|
540 | + public function selectAttachments(callable $filter) { |
|
541 | 541 | return $this->_select($this->getAttachments(), $filter); |
542 | 542 | } |
543 | 543 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @param callable $filter `fn( Story $comment ): bool` |
546 | 546 | * @return Story[] |
547 | 547 | */ |
548 | - public function selectComments (callable $filter) { |
|
548 | + public function selectComments(callable $filter) { |
|
549 | 549 | return $this->_select($this->getComments(), $filter); |
550 | 550 | } |
551 | 551 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | * @param callable $filter `fn( Task $dependency ): bool` |
554 | 554 | * @return Task[] |
555 | 555 | */ |
556 | - public function selectDependencies (callable $filter) { |
|
556 | + public function selectDependencies(callable $filter) { |
|
557 | 557 | return $this->_select($this->getDependencies(), $filter); |
558 | 558 | } |
559 | 559 | |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | * @param callable $filter `fn( Task $dependent ): bool` |
562 | 562 | * @return Task[] |
563 | 563 | */ |
564 | - public function selectDependents (callable $filter) { |
|
564 | + public function selectDependents(callable $filter) { |
|
565 | 565 | return $this->_select($this->getDependents(), $filter); |
566 | 566 | } |
567 | 567 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | * @param callable $filter `fn( Project $project ): bool` |
570 | 570 | * @return Project[] |
571 | 571 | */ |
572 | - public function selectProjects (callable $filter) { |
|
572 | + public function selectProjects(callable $filter) { |
|
573 | 573 | return $this->_select($this->getProjects(), $filter); |
574 | 574 | } |
575 | 575 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @param callable $filter `fn( Story $story ): bool` |
578 | 578 | * @return Story[] |
579 | 579 | */ |
580 | - public function selectStories (callable $filter) { |
|
580 | + public function selectStories(callable $filter) { |
|
581 | 581 | return $this->_select($this->getStories(), $filter); |
582 | 582 | } |
583 | 583 | |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | * @param callable $filter `fn( Task $subtask ): bool` |
586 | 586 | * @return Task[] |
587 | 587 | */ |
588 | - public function selectSubTasks (callable $filter) { |
|
588 | + public function selectSubTasks(callable $filter) { |
|
589 | 589 | return $this->_select($this->getSubTasks(), $filter); |
590 | 590 | } |
591 | 591 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * @param null|Task $parent |
597 | 597 | * @return $this |
598 | 598 | */ |
599 | - public function setParent (?self $parent) { |
|
599 | + public function setParent(?self $parent) { |
|
600 | 600 | return $this->_setWithPost("{$this}/setParent", [ |
601 | 601 | 'parent' => $parent |
602 | 602 | ], 'parent', $parent); |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | * @param bool $flag |
607 | 607 | * @return $this |
608 | 608 | */ |
609 | - public function setRenderedAsSeparator (bool $flag) { |
|
609 | + public function setRenderedAsSeparator(bool $flag) { |
|
610 | 610 | return $this->_set('is_rendered_as_separator', $flag); |
611 | 611 | } |
612 | 612 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | 'workspaces' => [Workspace::class] |
29 | 29 | ]; |
30 | 30 | |
31 | - final public function __toString (): string { |
|
31 | + final public function __toString(): string { |
|
32 | 32 | return "users/{$this->getGid()}"; |
33 | 33 | } |
34 | 34 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param Workspace $workspace |
37 | 37 | * @return $this |
38 | 38 | */ |
39 | - public function addToWorkspace (Workspace $workspace) { |
|
39 | + public function addToWorkspace(Workspace $workspace) { |
|
40 | 40 | return $this->_addWithPost("{$workspace}/addUser", [ |
41 | 41 | 'user' => $this->getGid() |
42 | 42 | ], 'workspaces', [$workspace]); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @return string[] |
47 | 47 | */ |
48 | - public function getCacheKeys () { |
|
48 | + public function getCacheKeys() { |
|
49 | 49 | $keys = parent::getCacheKeys(); |
50 | 50 | |
51 | 51 | // only include email as a key if it's loaded |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return Workspace |
64 | 64 | */ |
65 | - public function getDefaultWorkspace () { |
|
65 | + public function getDefaultWorkspace() { |
|
66 | 66 | return $this->getWorkspaces()[0]; |
67 | 67 | } |
68 | 68 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param null|Workspace $workspace Falls back to the default workspace. |
71 | 71 | * @return Portfolio[] |
72 | 72 | */ |
73 | - public function getFavoritePortfolios (Workspace $workspace = null) { |
|
73 | + public function getFavoritePortfolios(Workspace $workspace = null) { |
|
74 | 74 | return $this->getFavorites(Portfolio::class, Portfolio::TYPE, $workspace); |
75 | 75 | } |
76 | 76 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param null|Workspace $workspace Falls back to the default workspace. |
79 | 79 | * @return Project[] |
80 | 80 | */ |
81 | - public function getFavoriteProjects (Workspace $workspace = null) { |
|
81 | + public function getFavoriteProjects(Workspace $workspace = null) { |
|
82 | 82 | return $this->getFavorites(Project::class, Project::TYPE, $workspace); |
83 | 83 | } |
84 | 84 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param null|Workspace $workspace Falls back to the default workspace. |
87 | 87 | * @return Tag[] |
88 | 88 | */ |
89 | - public function getFavoriteTags (Workspace $workspace = null) { |
|
89 | + public function getFavoriteTags(Workspace $workspace = null) { |
|
90 | 90 | return $this->getFavorites(Tag::class, Tag::TYPE, $workspace); |
91 | 91 | } |
92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param null|Workspace $workspace Falls back to the default workspace. |
95 | 95 | * @return Team[] |
96 | 96 | */ |
97 | - public function getFavoriteTeams (Workspace $workspace = null) { |
|
97 | + public function getFavoriteTeams(Workspace $workspace = null) { |
|
98 | 98 | return $this->getFavorites(Team::class, Team::TYPE, $workspace); |
99 | 99 | } |
100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param null|Workspace $workspace Falls back to the default workspace. |
103 | 103 | * @return User[] |
104 | 104 | */ |
105 | - public function getFavoriteUsers (Workspace $workspace = null) { |
|
105 | + public function getFavoriteUsers(Workspace $workspace = null) { |
|
106 | 106 | return $this->getFavorites(self::class, self::TYPE, $workspace); |
107 | 107 | } |
108 | 108 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param null|Workspace $workspace Falls back to the default workspace. |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - protected function getFavorites (string $class, string $resourceType, Workspace $workspace = null) { |
|
115 | + protected function getFavorites(string $class, string $resourceType, Workspace $workspace = null) { |
|
116 | 116 | return $this->_loadAll($class, "{$this}/favorites", [ |
117 | 117 | 'resource_type' => $resourceType, |
118 | 118 | 'workspace' => ($workspace ?? $this->getDefaultWorkspace())->getGid() |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param null|Workspace $workspace |
124 | 124 | * @return Portfolio[] |
125 | 125 | */ |
126 | - public function getPortfolios (Workspace $workspace = null) { |
|
126 | + public function getPortfolios(Workspace $workspace = null) { |
|
127 | 127 | return $this->_loadAll(Portfolio::class, "portfolios", [ |
128 | 128 | 'workspace' => ($workspace ?? $this->getDefaultWorkspace())->getGid(), |
129 | 129 | 'owner' => $this->getGid() |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param null|Workspace $workspace Falls back to the default workspace. |
135 | 135 | * @return TaskList |
136 | 136 | */ |
137 | - public function getTaskList (Workspace $workspace = null) { |
|
137 | + public function getTaskList(Workspace $workspace = null) { |
|
138 | 138 | return $this->_load(TaskList::class, "{$this}/user_task_list", [ |
139 | 139 | 'workspace' => ($workspace ?? $this->getDefaultWorkspace())->getGid() |
140 | 140 | ]); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param string[] $filter `workspace` falls back to the default. |
147 | 147 | * @return Task[] |
148 | 148 | */ |
149 | - public function getTasks (array $filter = []) { |
|
149 | + public function getTasks(array $filter = []) { |
|
150 | 150 | $filter['assignee'] = $this->getGid(); |
151 | 151 | $filter += ['workspace' => $this->getDefaultWorkspace()->getGid()]; |
152 | 152 | return $this->_loadAll(Task::class, 'tasks', $filter); |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | * @param null|Workspace $organization Falls back to the default workspace. |
161 | 161 | * @return Team[] |
162 | 162 | */ |
163 | - public function getTeams (Workspace $organization = null) { |
|
163 | + public function getTeams(Workspace $organization = null) { |
|
164 | 164 | return $this->_loadAll(Team::class, "{$this}/teams", [ |
165 | 165 | 'organization' => ($organization ?? $this->getDefaultWorkspace())->getGid() |
166 | 166 | ]); |
167 | 167 | } |
168 | 168 | |
169 | - public function getUrl (): string { |
|
169 | + public function getUrl(): string { |
|
170 | 170 | return "https://app.asana.com/0/{$this->getGid()}/list"; |
171 | 171 | } |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param Workspace $workspace |
175 | 175 | * @return $this |
176 | 176 | */ |
177 | - public function removeFromWorkspace (Workspace $workspace) { |
|
177 | + public function removeFromWorkspace(Workspace $workspace) { |
|
178 | 178 | return $this->_removeWithPost("{$workspace}/removeUser", [ |
179 | 179 | 'user' => $this->getGid() |
180 | 180 | ], 'workspaces', [$workspace]); |