@@ -10,7 +10,7 @@ |
||
10 | 10 | /** |
11 | 11 | * `DELETE` |
12 | 12 | */ |
13 | - public function delete (): void { |
|
13 | + public function delete(): void { |
|
14 | 14 | $this->{'_delete'}(); |
15 | 15 | } |
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -12,7 +12,7 @@ |
||
12 | 12 | * |
13 | 13 | * @return $this |
14 | 14 | */ |
15 | - public function update () { |
|
15 | + public function update() { |
|
16 | 16 | return $this->{'_save'}(); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param Api|Data $caller |
48 | 48 | * @param array $data |
49 | 49 | */ |
50 | - public function __construct ($caller, array $data = []) { |
|
50 | + public function __construct($caller, array $data = []) { |
|
51 | 51 | $this->api = $caller instanceof self ? $caller->api : $caller; |
52 | 52 | $this->_setData($data); |
53 | 53 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | * @param array $args |
64 | 64 | * @return mixed |
65 | 65 | */ |
66 | - public function __call (string $method, array $args) { |
|
66 | + public function __call(string $method, array $args) { |
|
67 | 67 | static $cache = []; |
68 | - if (!$call =& $cache[$method]) { |
|
68 | + if (!$call = & $cache[$method]) { |
|
69 | 69 | preg_match('/^(get|has|is|set)(.+)$/', $method, $call); |
70 | 70 | $call[1] = '_' . $call[1]; |
71 | 71 | $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | return $this->{$call[1]}($call[2], ...$args); |
76 | 76 | } |
77 | 77 | |
78 | - public function __debugInfo (): array { |
|
78 | + public function __debugInfo(): array { |
|
79 | 79 | return $this->data; |
80 | 80 | } |
81 | 81 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param $field |
86 | 86 | * @return null|Data|mixed |
87 | 87 | */ |
88 | - final public function __get ($field) { |
|
88 | + final public function __get($field) { |
|
89 | 89 | return $this->_get($field); |
90 | 90 | } |
91 | 91 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param $field |
98 | 98 | * @return bool |
99 | 99 | */ |
100 | - final public function __isset ($field) { |
|
100 | + final public function __isset($field) { |
|
101 | 101 | return true; |
102 | 102 | } |
103 | 103 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param string $field |
110 | 110 | * @return mixed |
111 | 111 | */ |
112 | - protected function _get (string $field) { |
|
112 | + protected function _get(string $field) { |
|
113 | 113 | return $this->data[$field] ?? null; |
114 | 114 | } |
115 | 115 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param string $field |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | - protected function _has (string $field): bool { |
|
126 | + protected function _has(string $field): bool { |
|
127 | 127 | $value = $this->_get($field); |
128 | 128 | if (isset($value)) { |
129 | 129 | if (is_countable($value)) { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param string $field |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | - protected function _is (string $field): bool { |
|
149 | + protected function _is(string $field): bool { |
|
150 | 150 | return !empty($this->_get($field)); |
151 | 151 | } |
152 | 152 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param mixed $value |
160 | 160 | * @return $this |
161 | 161 | */ |
162 | - protected function _set (string $field, $value) { |
|
162 | + protected function _set(string $field, $value) { |
|
163 | 163 | $this->data[$field] = $value; |
164 | 164 | $this->diff[$field] = true; |
165 | 165 | return $this; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param array $data |
172 | 172 | */ |
173 | - protected function _setData (array $data): void { |
|
173 | + protected function _setData(array $data): void { |
|
174 | 174 | $this->data = $this->diff = []; |
175 | 175 | foreach ($data as $field => $value) { |
176 | 176 | $this->_setMapped($field, $value); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param string $field |
184 | 184 | * @param mixed $value |
185 | 185 | */ |
186 | - protected function _setMapped (string $field, $value): void { |
|
186 | + protected function _setMapped(string $field, $value): void { |
|
187 | 187 | unset($this->diff[$field]); |
188 | 188 | |
189 | 189 | // use value as-is? |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param array $data |
232 | 232 | * @return mixed|Data|AbstractEntity |
233 | 233 | */ |
234 | - final protected function factory (string $class, array $data = []) { |
|
234 | + final protected function factory(string $class, array $data = []) { |
|
235 | 235 | return $this->api->factory($class, $this, $data); |
236 | 236 | } |
237 | 237 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return array |
242 | 242 | */ |
243 | - public function getDiff (): array { |
|
243 | + public function getDiff(): array { |
|
244 | 244 | $convert = function($each) use (&$convert) { |
245 | 245 | // convert existing entities to gids |
246 | 246 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return bool |
267 | 267 | */ |
268 | - final public function isDiff (): bool { |
|
268 | + final public function isDiff(): bool { |
|
269 | 269 | return (bool)$this->diff; |
270 | 270 | } |
271 | 271 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @see toArray() |
274 | 274 | * @return array |
275 | 275 | */ |
276 | - public function jsonSerialize (): array { |
|
276 | + public function jsonSerialize(): array { |
|
277 | 277 | return $this->toArray(); |
278 | 278 | } |
279 | 279 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param array $query |
288 | 288 | * @return null|mixed|AbstractEntity |
289 | 289 | */ |
290 | - final protected function load (string $class, string $path, array $query = []) { |
|
290 | + final protected function load(string $class, string $path, array $query = []) { |
|
291 | 291 | return $this->api->load($class, $this, $path, $query); |
292 | 292 | } |
293 | 293 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param int $pages |
303 | 303 | * @return array|AbstractEntity[] |
304 | 304 | */ |
305 | - final protected function loadAll (string $class, string $path, array $query = [], int $pages = 0) { |
|
305 | + final protected function loadAll(string $class, string $path, array $query = [], int $pages = 0) { |
|
306 | 306 | return $this->api->loadAll($class, $this, $path, $query, $pages); |
307 | 307 | } |
308 | 308 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return string |
313 | 313 | */ |
314 | - public function serialize (): string { |
|
314 | + public function serialize(): string { |
|
315 | 315 | return json_encode($this); |
316 | 316 | } |
317 | 317 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @return array |
322 | 322 | */ |
323 | - public function toArray (): array { |
|
323 | + public function toArray(): array { |
|
324 | 324 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
325 | 325 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
326 | 326 | return $each->getGid(); |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @param $serialized |
342 | 342 | */ |
343 | - public function unserialize ($serialized): void { |
|
343 | + public function unserialize($serialized): void { |
|
344 | 344 | $this->api = Api::getDefault(); |
345 | 345 | $data = json_decode($serialized, true); |
346 | 346 | $this->_setData($data); |
@@ -218,8 +218,7 @@ discard block |
||
218 | 218 | if (is_array($class)) { |
219 | 219 | $class = $class[0]; |
220 | 220 | $this->data[$field] = array_map($hydrate, $value); |
221 | - } |
|
222 | - else { |
|
221 | + } else { |
|
223 | 222 | $this->data[$field] = $hydrate($value); |
224 | 223 | } |
225 | 224 | } |
@@ -324,11 +323,9 @@ discard block |
||
324 | 323 | return array_map($dehydrate = function($each) use (&$dehydrate) { |
325 | 324 | if ($each instanceof AbstractEntity and $each->hasGid()) { |
326 | 325 | return $each->getGid(); |
327 | - } |
|
328 | - elseif ($each instanceof self) { |
|
326 | + } elseif ($each instanceof self) { |
|
329 | 327 | return $each->toArray(); |
330 | - } |
|
331 | - elseif (is_array($each)) { |
|
328 | + } elseif (is_array($each)) { |
|
332 | 329 | return array_map($dehydrate, $each); |
333 | 330 | } |
334 | 331 | return $each; |
@@ -52,25 +52,25 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @return Cache |
54 | 54 | */ |
55 | - public static function getCache () { |
|
55 | + public static function getCache() { |
|
56 | 56 | return static::$cache ?? static::$cache = new Cache(); |
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @return Api |
61 | 61 | */ |
62 | - public static function getDefault () { |
|
62 | + public static function getDefault() { |
|
63 | 63 | return self::$default; |
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @return LoggerInterface |
68 | 68 | */ |
69 | - public static function getLogger () { |
|
69 | + public static function getLogger() { |
|
70 | 70 | return static::$logger |
71 | 71 | ?? static::$logger = new class implements LoggerInterface { |
72 | 72 | |
73 | - public function log (string $message, string $path, array $data = null): void { |
|
73 | + public function log(string $message, string $path, array $data = null): void { |
|
74 | 74 | // stub |
75 | 75 | } |
76 | 76 | |
@@ -80,28 +80,28 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * @param Cache $cache |
82 | 82 | */ |
83 | - public static function setCache (Cache $cache) { |
|
83 | + public static function setCache(Cache $cache) { |
|
84 | 84 | static::$cache = $cache; |
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
88 | 88 | * @param Api $default |
89 | 89 | */ |
90 | - public static function setDefault (Api $default) { |
|
90 | + public static function setDefault(Api $default) { |
|
91 | 91 | self::$default = $default; |
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
95 | 95 | * @param LoggerInterface $logger |
96 | 96 | */ |
97 | - public static function setLogger (LoggerInterface $logger) { |
|
97 | + public static function setLogger(LoggerInterface $logger) { |
|
98 | 98 | static::$logger = $logger; |
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
102 | 102 | * @param string $token |
103 | 103 | */ |
104 | - public function __construct (string $token) { |
|
104 | + public function __construct(string $token) { |
|
105 | 105 | $this->token = $token; |
106 | 106 | if (!static::$default) { |
107 | 107 | static::$default = $this; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return null|array |
118 | 118 | * @internal |
119 | 119 | */ |
120 | - protected function _exec (string $method, string $path, array $opts = []) { |
|
120 | + protected function _exec(string $method, string $path, array $opts = []) { |
|
121 | 121 | static::getLogger()->log($method, $path, $opts); |
122 | 122 | /** @var resource $ch */ |
123 | 123 | $ch = curl_init(); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return string |
167 | 167 | * @internal |
168 | 168 | */ |
169 | - protected function _getPath (string $path, array $query): string { |
|
169 | + protected function _getPath(string $path, array $query): string { |
|
170 | 170 | return $query ? $path . '?' . http_build_query($query) : $path; |
171 | 171 | } |
172 | 172 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @return null|array |
176 | 176 | * @internal |
177 | 177 | */ |
178 | - protected function _jsonDecode (string $json) { |
|
179 | - return json_decode($json, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
178 | + protected function _jsonDecode(string $json) { |
|
179 | + return json_decode($json, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @return string |
185 | 185 | * @internal |
186 | 186 | */ |
187 | - protected function _jsonEncode (array $data): string { |
|
188 | - return json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
|
187 | + protected function _jsonEncode(array $data): string { |
|
188 | + return json_encode($data, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param string $path |
195 | 195 | */ |
196 | - public function delete (string $path): void { |
|
196 | + public function delete(string $path): void { |
|
197 | 197 | $this->_exec('DELETE', $path); |
198 | 198 | } |
199 | 199 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param array $data |
208 | 208 | * @return mixed|Data|AbstractEntity |
209 | 209 | */ |
210 | - public function factory (string $class, $caller, array $data = []) { |
|
210 | + public function factory(string $class, $caller, array $data = []) { |
|
211 | 211 | return new $class($caller, $data); |
212 | 212 | } |
213 | 213 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param array $options |
220 | 220 | * @return null|array |
221 | 221 | */ |
222 | - public function get (string $path, array $query = [], array $options = []) { |
|
222 | + public function get(string $path, array $query = [], array $options = []) { |
|
223 | 223 | foreach ($options as $name => $value) { |
224 | 224 | $query["opt_{$name}"] = $value; |
225 | 225 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @param string $gid |
234 | 234 | * @return null|Attachment |
235 | 235 | */ |
236 | - public function getAttachment (string $gid) { |
|
236 | + public function getAttachment(string $gid) { |
|
237 | 237 | return $this->load(Attachment::class, $this, "attachments/{$gid}"); |
238 | 238 | } |
239 | 239 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @param string $gid |
244 | 244 | * @return null|CustomField |
245 | 245 | */ |
246 | - public function getCustomField (string $gid) { |
|
246 | + public function getCustomField(string $gid) { |
|
247 | 247 | return $this->load(CustomField::class, $this, "custom_fields/{$gid}"); |
248 | 248 | } |
249 | 249 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return User |
254 | 254 | */ |
255 | - public function getMe () { |
|
255 | + public function getMe() { |
|
256 | 256 | return $this->getUser('me'); |
257 | 257 | } |
258 | 258 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param string $gid |
263 | 263 | * @return null|Portfolio |
264 | 264 | */ |
265 | - public function getPortfolio (string $gid) { |
|
265 | + public function getPortfolio(string $gid) { |
|
266 | 266 | return $this->load(Portfolio::class, $this, "portfolios/{$gid}"); |
267 | 267 | } |
268 | 268 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param string $gid |
273 | 273 | * @return null|Project |
274 | 274 | */ |
275 | - public function getProject (string $gid) { |
|
275 | + public function getProject(string $gid) { |
|
276 | 276 | return $this->load(Project::class, $this, "projects/{$gid}"); |
277 | 277 | } |
278 | 278 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param string $gid |
283 | 283 | * @return null|Section |
284 | 284 | */ |
285 | - public function getSection (string $gid) { |
|
285 | + public function getSection(string $gid) { |
|
286 | 286 | return $this->load(Section::class, $this, "sections/{$gid}"); |
287 | 287 | } |
288 | 288 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @param string $gid |
293 | 293 | * @return null|Story |
294 | 294 | */ |
295 | - public function getStory (string $gid) { |
|
295 | + public function getStory(string $gid) { |
|
296 | 296 | return $this->load(Story::class, $this, "stories/{$gid}"); |
297 | 297 | } |
298 | 298 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param string $gid |
303 | 303 | * @return null|Tag |
304 | 304 | */ |
305 | - public function getTag (string $gid) { |
|
305 | + public function getTag(string $gid) { |
|
306 | 306 | return $this->load(Tag::class, $this, "tags/{$gid}"); |
307 | 307 | } |
308 | 308 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @param string $gid |
313 | 313 | * @return null|Task |
314 | 314 | */ |
315 | - public function getTask (string $gid) { |
|
315 | + public function getTask(string $gid) { |
|
316 | 316 | return $this->load(Task::class, $this, "tasks/{$gid}"); |
317 | 317 | } |
318 | 318 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @param string $gid |
323 | 323 | * @return null|Team |
324 | 324 | */ |
325 | - public function getTeam (string $gid) { |
|
325 | + public function getTeam(string $gid) { |
|
326 | 326 | return $this->load(Team::class, $this, "teams/{$gid}"); |
327 | 327 | } |
328 | 328 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @param string $gid |
333 | 333 | * @return null|User |
334 | 334 | */ |
335 | - public function getUser (string $gid) { |
|
335 | + public function getUser(string $gid) { |
|
336 | 336 | return $this->load(User::class, $this, "users/{$gid}"); |
337 | 337 | } |
338 | 338 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @param array $data |
345 | 345 | * @return ProjectEvent|TaskEvent|StoryEvent |
346 | 346 | */ |
347 | - public function getWebhookEvent (array $data) { |
|
347 | + public function getWebhookEvent(array $data) { |
|
348 | 348 | static $classes = [ |
349 | 349 | Project::TYPE => ProjectEvent::class, |
350 | 350 | Task::TYPE => TaskEvent::class, |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @param string $gid |
360 | 360 | * @return null|Workspace |
361 | 361 | */ |
362 | - public function getWorkspace (string $gid) { |
|
362 | + public function getWorkspace(string $gid) { |
|
363 | 363 | return $this->load(Workspace::class, $this, "workspaces/{$gid}"); |
364 | 364 | } |
365 | 365 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @param string $name |
370 | 370 | * @return null|Workspace |
371 | 371 | */ |
372 | - public function getWorkspaceByName (string $name) { |
|
372 | + public function getWorkspaceByName(string $name) { |
|
373 | 373 | foreach ($this->getMe()->getWorkspaces() as $workspace) { |
374 | 374 | if ($workspace->getName() === $name) { |
375 | 375 | return $workspace; |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @param array $query |
390 | 390 | * @return null|mixed|AbstractEntity |
391 | 391 | */ |
392 | - public function load (string $class, $caller, string $path, array $query = []) { |
|
392 | + public function load(string $class, $caller, string $path, array $query = []) { |
|
393 | 393 | $key = $this->_getPath($path, $query); |
394 | 394 | return $this->getCache()->get($key, $caller, function($caller) use ($class, $path, $query) { |
395 | 395 | $data = $this->get($path, $query, ['expand' => 'this']); |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @param int $pages If positive, stops after this many pages have been fetched. |
410 | 410 | * @return array|AbstractEntity[] |
411 | 411 | */ |
412 | - public function loadAll (string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
412 | + public function loadAll(string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
413 | 413 | $query['opt_expand'] = 'this'; |
414 | 414 | $query += ['limit' => 100]; |
415 | 415 | $path = $this->_getPath($path, $query); |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @param array $options |
436 | 436 | * @return null|array |
437 | 437 | */ |
438 | - public function post (string $path, array $data = [], array $options = []) { |
|
438 | + public function post(string $path, array $data = [], array $options = []) { |
|
439 | 439 | $response = $this->_exec('POST', $path, [ |
440 | 440 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
441 | 441 | CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data]) |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * @param array $options |
452 | 452 | * @return null|array |
453 | 453 | */ |
454 | - public function put (string $path, array $data = [], array $options = []) { |
|
454 | + public function put(string $path, array $data = [], array $options = []) { |
|
455 | 455 | $response = $this->_exec('PUT', $path, [ |
456 | 456 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
457 | 457 | CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data]) |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @param null|string $token |
471 | 471 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
472 | 472 | */ |
473 | - public function sync ($entity, ?string &$token) { |
|
473 | + public function sync($entity, ?string &$token) { |
|
474 | 474 | try { |
475 | 475 | $response = $this->_exec('GET', $this->_getPath('events', [ |
476 | 476 | 'resource' => $entity->getGid(), |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * @param string $file |
506 | 506 | * @return null|array |
507 | 507 | */ |
508 | - public function upload (string $path, string $file) { |
|
508 | + public function upload(string $path, string $file) { |
|
509 | 509 | $response = $this->_exec('POST', $path, [ |
510 | 510 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
511 | 511 | ]); |
@@ -33,23 +33,23 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected $customField; |
35 | 35 | |
36 | - public function __construct (CustomField $customField, array $data = []) { |
|
36 | + public function __construct(CustomField $customField, array $data = []) { |
|
37 | 37 | parent::__construct($customField, $data); |
38 | 38 | $this->customField = $customField; |
39 | 39 | } |
40 | 40 | |
41 | - final public function __toString (): string { |
|
41 | + final public function __toString(): string { |
|
42 | 42 | return "enum_options/{$this->getGid()}"; |
43 | 43 | } |
44 | 44 | |
45 | - final protected function _getDir (): string { |
|
45 | + final protected function _getDir(): string { |
|
46 | 46 | return "{$this->customField}/enum_options"; |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @return CustomField |
51 | 51 | */ |
52 | - public function getCustomField () { |
|
52 | + public function getCustomField() { |
|
53 | 53 | return $this->customField; |
54 | 54 | } |
55 | 55 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param EnumOption $option |
59 | 59 | * @return $this |
60 | 60 | */ |
61 | - public function moveAfter (EnumOption $option) { |
|
61 | + public function moveAfter(EnumOption $option) { |
|
62 | 62 | $this->api->post("{$this->_getDir()}/insert", [ |
63 | 63 | 'after_enum_option' => $option->getGid(), |
64 | 64 | 'enum_option' => $this->getGid() |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param EnumOption $option |
73 | 73 | * @return $this |
74 | 74 | */ |
75 | - public function moveBefore (EnumOption $option) { |
|
75 | + public function moveBefore(EnumOption $option) { |
|
76 | 76 | $this->api->post("{$this->_getDir()}/insert", [ |
77 | 77 | 'before_enum_option' => $option->getGid(), |
78 | 78 | 'enum_option' => $this->getGid() |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | /** |
85 | 85 | * @return $this |
86 | 86 | */ |
87 | - public function moveFirst () { |
|
87 | + public function moveFirst() { |
|
88 | 88 | $first = $this->customField->getEnumOptions()[0]; |
89 | 89 | if ($first !== $this) { |
90 | 90 | $this->moveBefore($first); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | /** |
96 | 96 | * @return $this |
97 | 97 | */ |
98 | - public function moveLast () { |
|
98 | + public function moveLast() { |
|
99 | 99 | $options = $this->customField->getEnumOptions(); |
100 | 100 | $last = $options[count($options) - 1]; |
101 | 101 | if ($last !== $this) { |
@@ -91,15 +91,15 @@ discard block |
||
91 | 91 | 'memberships' => 'memberships.(project|section)' |
92 | 92 | ]; |
93 | 93 | |
94 | - final public function __toString (): string { |
|
94 | + final public function __toString(): string { |
|
95 | 95 | return "tasks/{$this->getGid()}"; |
96 | 96 | } |
97 | 97 | |
98 | - final protected function _getDir (): string { |
|
98 | + final protected function _getDir(): string { |
|
99 | 99 | return 'tasks'; |
100 | 100 | } |
101 | 101 | |
102 | - protected function _save (string $dir = null) { |
|
102 | + protected function _save(string $dir = null) { |
|
103 | 103 | parent::_save($dir); |
104 | 104 | // use isset() to avoid has() fetch. |
105 | 105 | if (isset($this->data['custom_fields'])) { |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | return $this; |
112 | 112 | } |
113 | 113 | |
114 | - protected function _setData (array $data): void { |
|
114 | + protected function _setData(array $data): void { |
|
115 | 115 | unset($data['hearted']); // deprecated for likes |
116 | 116 | unset($data['hearts']); // deprecated for likes |
117 | 117 | unset($data['projects']); // redundant, memberships are used instead |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param string $file |
126 | 126 | * @return Attachment |
127 | 127 | */ |
128 | - public function addAttachment (string $file) { |
|
128 | + public function addAttachment(string $file) { |
|
129 | 129 | /** @var Attachment $attachment */ |
130 | 130 | $attachment = $this->factory(Attachment::class, ['parent' => $this]); |
131 | 131 | return $attachment->upload($file); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param string $text |
138 | 138 | * @return Story |
139 | 139 | */ |
140 | - public function addComment (string $text) { |
|
140 | + public function addComment(string $text) { |
|
141 | 141 | return $this->newComment()->setText($text)->create(); |
142 | 142 | } |
143 | 143 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param Task[] $tasks |
149 | 149 | * @return $this |
150 | 150 | */ |
151 | - public function addDependencies (array $tasks) { |
|
151 | + public function addDependencies(array $tasks) { |
|
152 | 152 | $this->api->post("{$this}/addDependencies", ['dependents' => array_column($tasks, 'gid')]); |
153 | 153 | return $this; |
154 | 154 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @param Task $task |
161 | 161 | * @return $this |
162 | 162 | */ |
163 | - public function addDependency (Task $task) { |
|
163 | + public function addDependency(Task $task) { |
|
164 | 164 | return $this->addDependencies([$task]); |
165 | 165 | } |
166 | 166 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param Task $task |
172 | 172 | * @return $this |
173 | 173 | */ |
174 | - public function addDependent (Task $task) { |
|
174 | + public function addDependent(Task $task) { |
|
175 | 175 | return $this->addDependents([$task]); |
176 | 176 | } |
177 | 177 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param Task[] $tasks |
183 | 183 | * @return $this |
184 | 184 | */ |
185 | - public function addDependents (array $tasks) { |
|
185 | + public function addDependents(array $tasks) { |
|
186 | 186 | $this->api->post("{$this}/addDependents", ['dependents' => array_column($tasks, 'gid')]); |
187 | 187 | return $this; |
188 | 188 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @param User $user |
194 | 194 | * @return $this |
195 | 195 | */ |
196 | - public function addFollower (User $user) { |
|
196 | + public function addFollower(User $user) { |
|
197 | 197 | return $this->addFollowers([$user]); |
198 | 198 | } |
199 | 199 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param User[] $users |
206 | 206 | * @return $this |
207 | 207 | */ |
208 | - public function addFollowers (array $users) { |
|
208 | + public function addFollowers(array $users) { |
|
209 | 209 | return $this->_addWithPost("{$this}/addFollowers", [ |
210 | 210 | 'followers' => array_column($users, 'gid') |
211 | 211 | ], 'followers', $users); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param Tag $tag |
220 | 220 | * @return $this |
221 | 221 | */ |
222 | - public function addTag (Tag $tag) { |
|
222 | + public function addTag(Tag $tag) { |
|
223 | 223 | return $this->_addWithPost("{$this}/addTag", [ |
224 | 224 | 'tag' => $tag->getGid() |
225 | 225 | ], 'tags', [$tag]); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @param Section|null $section |
235 | 235 | * @return $this |
236 | 236 | */ |
237 | - public function addToProject (Project $project, Section $section = null) { |
|
237 | + public function addToProject(Project $project, Section $section = null) { |
|
238 | 238 | /** @var Membership $membership */ |
239 | 239 | $membership = $this->factory(Membership::class) |
240 | 240 | ->_set('project', $project) |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param string $target |
250 | 250 | * @return TaskWebhook |
251 | 251 | */ |
252 | - public function addWebhook (string $target) { |
|
252 | + public function addWebhook(string $target) { |
|
253 | 253 | /** @var TaskWebhook $webhook */ |
254 | 254 | $webhook = $this->factory(TaskWebhook::class); |
255 | 255 | return $webhook->create($this, $target); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * @param string[] $include |
266 | 266 | * @return Job |
267 | 267 | */ |
268 | - public function duplicate (string $name, array $include) { |
|
268 | + public function duplicate(string $name, array $include) { |
|
269 | 269 | /** @var array $remote */ |
270 | 270 | $remote = $this->api->post("{$this}/duplicate", [ |
271 | 271 | 'name' => $name, |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @depends after-create |
281 | 281 | * @return Attachment[] |
282 | 282 | */ |
283 | - public function getAttachments () { |
|
283 | + public function getAttachments() { |
|
284 | 284 | return $this->loadAll(Attachment::class, "{$this}/attachments"); |
285 | 285 | } |
286 | 286 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @depends after-create |
291 | 291 | * @return Story[] |
292 | 292 | */ |
293 | - public function getComments () { |
|
293 | + public function getComments() { |
|
294 | 294 | return array_values(array_filter($this->getStories(), function(Story $story) { |
295 | 295 | return $story->isComment(); |
296 | 296 | })); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @depends after-create |
303 | 303 | * @return Task[] |
304 | 304 | */ |
305 | - public function getDependencies () { |
|
305 | + public function getDependencies() { |
|
306 | 306 | return $this->loadAll(self::class, "{$this}/dependencies"); |
307 | 307 | } |
308 | 308 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @depends after-create |
313 | 313 | * @return Task[] |
314 | 314 | */ |
315 | - public function getDependents () { |
|
315 | + public function getDependents() { |
|
316 | 316 | return $this->loadAll(self::class, "{$this}/dependents"); |
317 | 317 | } |
318 | 318 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param null|string $token |
324 | 324 | * @return TaskEvent[]|StoryEvent[] |
325 | 325 | */ |
326 | - public function getEvents (&$token) { |
|
326 | + public function getEvents(&$token) { |
|
327 | 327 | return $this->api->sync($this, $token); |
328 | 328 | } |
329 | 329 | |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return External |
337 | 337 | */ |
338 | - public function getExternal () { |
|
338 | + public function getExternal() { |
|
339 | 339 | return $this->_get('external') ?? $this->data['external'] = $this->factory(External::class); |
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
343 | 343 | * @return Project[] |
344 | 344 | */ |
345 | - public function getProjects () { |
|
345 | + public function getProjects() { |
|
346 | 346 | return array_map(function(Membership $membership) { |
347 | 347 | return $membership->getProject(); |
348 | 348 | }, $this->getMemberships()); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @depends after-create |
355 | 355 | * @return Story[] |
356 | 356 | */ |
357 | - public function getStories () { |
|
357 | + public function getStories() { |
|
358 | 358 | return $this->loadAll(Story::class, "{$this}/stories"); |
359 | 359 | } |
360 | 360 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @depends after-create |
365 | 365 | * @return Task[] |
366 | 366 | */ |
367 | - public function getSubTasks () { |
|
367 | + public function getSubTasks() { |
|
368 | 368 | return $this->loadAll(self::class, "{$this}/subtasks"); |
369 | 369 | } |
370 | 370 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @depends after-create |
375 | 375 | * @return string |
376 | 376 | */ |
377 | - public function getUrl (): string { |
|
377 | + public function getUrl(): string { |
|
378 | 378 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
379 | 379 | } |
380 | 380 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @depends after-create |
385 | 385 | * @return TaskWebhook[] |
386 | 386 | */ |
387 | - public function getWebhooks () { |
|
387 | + public function getWebhooks() { |
|
388 | 388 | return $this->loadAll(TaskWebhook::class, 'webhooks', [ |
389 | 389 | 'workspace' => $this->getWorkspace()->getGid(), |
390 | 390 | 'resource' => $this->getGid() |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | /** |
395 | 395 | * @return bool |
396 | 396 | */ |
397 | - public function isRenderedAsSeparator (): bool { |
|
397 | + public function isRenderedAsSeparator(): bool { |
|
398 | 398 | return $this->_is('is_rendered_as_separator'); |
399 | 399 | } |
400 | 400 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @depends after-create |
405 | 405 | * @return Story |
406 | 406 | */ |
407 | - public function newComment () { |
|
407 | + public function newComment() { |
|
408 | 408 | /** @var Story $comment */ |
409 | 409 | $comment = $this->factory(Story::class, [ |
410 | 410 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @depends after-create |
419 | 419 | * @return Task |
420 | 420 | */ |
421 | - public function newSubTask () { |
|
421 | + public function newSubTask() { |
|
422 | 422 | /** @var Task $sub */ |
423 | 423 | $sub = $this->factory(self::class); |
424 | 424 | return $sub->setParent($this); |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @param Task[] $tasks |
432 | 432 | * @return $this |
433 | 433 | */ |
434 | - public function removeDependencies (array $tasks) { |
|
434 | + public function removeDependencies(array $tasks) { |
|
435 | 435 | $this->api->post("{$this}/removeDependencies", ['dependencies' => array_column($tasks, 'gid')]); |
436 | 436 | return $this; |
437 | 437 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * @param Task $task |
444 | 444 | * @return $this |
445 | 445 | */ |
446 | - public function removeDependency (Task $task) { |
|
446 | + public function removeDependency(Task $task) { |
|
447 | 447 | return $this->removeDependencies([$task]); |
448 | 448 | } |
449 | 449 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * @param Task $task |
455 | 455 | * @return $this |
456 | 456 | */ |
457 | - public function removeDependent (Task $task) { |
|
457 | + public function removeDependent(Task $task) { |
|
458 | 458 | return $this->removeDependents([$task]); |
459 | 459 | } |
460 | 460 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | * @param Task[] $tasks |
466 | 466 | * @return $this |
467 | 467 | */ |
468 | - public function removeDependents (array $tasks) { |
|
468 | + public function removeDependents(array $tasks) { |
|
469 | 469 | $this->api->post("{$this}/removeDependents", ['dependents' => array_column($tasks, 'gid')]); |
470 | 470 | return $this; |
471 | 471 | } |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @param User $user |
477 | 477 | * @return $this |
478 | 478 | */ |
479 | - public function removeFollower (User $user) { |
|
479 | + public function removeFollower(User $user) { |
|
480 | 480 | return $this->removeFollowers([$user]); |
481 | 481 | } |
482 | 482 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | * @param User[] $users |
489 | 489 | * @return $this |
490 | 490 | */ |
491 | - public function removeFollowers (array $users) { |
|
491 | + public function removeFollowers(array $users) { |
|
492 | 492 | return $this->_removeWithPost("{$this}/removeFollowers", [ |
493 | 493 | 'followers' => array_column($users, 'gid') |
494 | 494 | ], 'followers', $users); |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param Project $project |
503 | 503 | * @return $this |
504 | 504 | */ |
505 | - public function removeFromProject (Project $project) { |
|
505 | + public function removeFromProject(Project $project) { |
|
506 | 506 | return $this->_removeWithPost("{$this}/removeProject", [ |
507 | 507 | 'project' => $project->getGid() |
508 | 508 | ], 'memberships', function(Membership $membership) use ($project) { |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @param Tag $tag |
519 | 519 | * @return $this |
520 | 520 | */ |
521 | - public function removeTag (Tag $tag) { |
|
521 | + public function removeTag(Tag $tag) { |
|
522 | 522 | return $this->_removeWithPost("{$this}/removeTag", [ |
523 | 523 | 'tag' => $tag->getGid() |
524 | 524 | ], 'tags', [$tag]); |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | * @param null|Task $parent |
532 | 532 | * @return $this |
533 | 533 | */ |
534 | - public function setParent (?self $parent) { |
|
534 | + public function setParent(?self $parent) { |
|
535 | 535 | return $this->_setWithPost("{$this}/setParent", [ |
536 | 536 | 'parent' => $parent |
537 | 537 | ], 'parent', $parent); |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * @param bool $flag |
542 | 542 | * @return $this |
543 | 543 | */ |
544 | - public function setRenderedAsSeparator (bool $flag) { |
|
544 | + public function setRenderedAsSeparator(bool $flag) { |
|
545 | 545 | return $this->_set('is_rendered_as_separator', $flag); |
546 | 546 | } |
547 | 547 |