@@ -205,8 +205,7 @@ discard block |
||
| 205 | 205 | if ($this->hasGid()) { |
| 206 | 206 | $this->api->post("{$this}/addFollowers", ['followers' => array_column($users, 'gid')]); |
| 207 | 207 | $this->_merge('followers', $users); |
| 208 | - } |
|
| 209 | - else { |
|
| 208 | + } else { |
|
| 210 | 209 | $this->_merge('followers', $users, true); |
| 211 | 210 | } |
| 212 | 211 | return $this; |
@@ -222,8 +221,7 @@ discard block |
||
| 222 | 221 | if ($this->hasGid()) { |
| 223 | 222 | $this->api->post("{$this}/addTag", ['tag' => $tag->getGid()]); |
| 224 | 223 | $this->_merge('tags', [$tag]); |
| 225 | - } |
|
| 226 | - else { |
|
| 224 | + } else { |
|
| 227 | 225 | $this->_merge('tags', [$tag], true); |
| 228 | 226 | } |
| 229 | 227 | return $this; |
@@ -239,8 +237,7 @@ discard block |
||
| 239 | 237 | if ($target instanceof Project) { |
| 240 | 238 | $project = $target; |
| 241 | 239 | $section = null; |
| 242 | - } |
|
| 243 | - else { |
|
| 240 | + } else { |
|
| 244 | 241 | $project = $target->getProject(); |
| 245 | 242 | $section = $target; |
| 246 | 243 | } |
@@ -255,8 +252,7 @@ discard block |
||
| 255 | 252 | 'section' => $section |
| 256 | 253 | ]) |
| 257 | 254 | ]); |
| 258 | - } |
|
| 259 | - else { |
|
| 255 | + } else { |
|
| 260 | 256 | if (!$this->hasWorkspace() and $workspace = $project->getWorkspace()) { |
| 261 | 257 | $this->setWorkspace($workspace); |
| 262 | 258 | } |
@@ -567,8 +563,7 @@ discard block |
||
| 567 | 563 | if ($this->hasGid()) { |
| 568 | 564 | $this->api->post("{$this}/setParent", ['parent' => $parent ? $parent->getGid() : null]); |
| 569 | 565 | $this->data['parent'] = $parent; |
| 570 | - } |
|
| 571 | - else { |
|
| 566 | + } else { |
|
| 572 | 567 | $this->_set('parent', $parent); |
| 573 | 568 | } |
| 574 | 569 | return $this; |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | $this->data[$key] = array_values(array_unique($this->data[$key])); |
| 64 | 64 | if ($force) { |
| 65 | 65 | $this->diff[$key] = true; |
| 66 | - } |
|
| 67 | - else { |
|
| 66 | + } else { |
|
| 68 | 67 | $this->_cache(); |
| 69 | 68 | } |
| 70 | 69 | } |
@@ -105,8 +104,7 @@ discard block |
||
| 105 | 104 | if (isset($key)) { |
| 106 | 105 | $value = $this->api->get($this, [], ['fields' => static::$optFields[$key] ?? $key])[$key] ?? null; |
| 107 | 106 | $this->_setMapped($key, $value); |
| 108 | - } |
|
| 109 | - else { |
|
| 107 | + } else { |
|
| 110 | 108 | $this->_setData($this->api->get($this, [], ['expand' => 'this']) ?? []); |
| 111 | 109 | } |
| 112 | 110 | $this->_cache(); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | /** |
| 14 | 14 | * `DELETE` |
| 15 | 15 | */ |
| 16 | - public function delete (): void { |
|
| 16 | + public function delete(): void { |
|
| 17 | 17 | /** @var Api $api */ |
| 18 | 18 | $api = $this->api; |
| 19 | 19 | /** @var AbstractEntity $that */ |
@@ -52,24 +52,24 @@ 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 ?? static::$logger = new class implements LoggerInterface { |
| 71 | 71 | |
| 72 | - public function log (string $info, string $path, ?array $payload): void { |
|
| 72 | + public function log(string $info, string $path, ?array $payload): void { |
|
| 73 | 73 | // stub |
| 74 | 74 | } |
| 75 | 75 | |
@@ -79,28 +79,28 @@ discard block |
||
| 79 | 79 | /** |
| 80 | 80 | * @param Cache $cache |
| 81 | 81 | */ |
| 82 | - public static function setCache (Cache $cache) { |
|
| 82 | + public static function setCache(Cache $cache) { |
|
| 83 | 83 | static::$cache = $cache; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * @param Api $default |
| 88 | 88 | */ |
| 89 | - public static function setDefault (Api $default) { |
|
| 89 | + public static function setDefault(Api $default) { |
|
| 90 | 90 | self::$default = $default; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * @param LoggerInterface $logger |
| 95 | 95 | */ |
| 96 | - public static function setLogger (LoggerInterface $logger) { |
|
| 96 | + public static function setLogger(LoggerInterface $logger) { |
|
| 97 | 97 | static::$logger = $logger; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * @param string $token |
| 102 | 102 | */ |
| 103 | - public function __construct (string $token) { |
|
| 103 | + public function __construct(string $token) { |
|
| 104 | 104 | $this->token = $token; |
| 105 | 105 | if (!static::$default) { |
| 106 | 106 | static::$default = $this; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @param string $path |
| 114 | 114 | */ |
| 115 | - public function delete (string $path): void { |
|
| 115 | + public function delete(string $path): void { |
|
| 116 | 116 | $this->exec('DELETE', $path); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @return null|array |
| 124 | 124 | * @internal |
| 125 | 125 | */ |
| 126 | - protected function exec (string $method, string $path, array $opts = null) { |
|
| 126 | + protected function exec(string $method, string $path, array $opts = null) { |
|
| 127 | 127 | /** @var resource $ch */ |
| 128 | 128 | $ch = curl_init(); |
| 129 | 129 | curl_setopt_array($ch, [ |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | * @param array $data |
| 178 | 178 | * @return mixed|Data|AbstractEntity |
| 179 | 179 | */ |
| 180 | - public function factory (string $class, $caller, array $data = []) { |
|
| 180 | + public function factory(string $class, $caller, array $data = []) { |
|
| 181 | 181 | return new $class($caller, $data); |
| 182 | 182 | } |
| 183 | 183 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param array $options |
| 190 | 190 | * @return null|array |
| 191 | 191 | */ |
| 192 | - public function get (string $path, array $query = [], array $options = []) { |
|
| 192 | + public function get(string $path, array $query = [], array $options = []) { |
|
| 193 | 193 | foreach ($options as $name => $value) { |
| 194 | 194 | $query["opt_{$name}"] = $value; |
| 195 | 195 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @param string $gid |
| 204 | 204 | * @return null|Attachment |
| 205 | 205 | */ |
| 206 | - public function getAttachment (string $gid) { |
|
| 206 | + public function getAttachment(string $gid) { |
|
| 207 | 207 | return $this->load(Attachment::class, $this, "attachments/{$gid}"); |
| 208 | 208 | } |
| 209 | 209 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @param string $gid |
| 214 | 214 | * @return null|CustomField |
| 215 | 215 | */ |
| 216 | - public function getCustomField (string $gid) { |
|
| 216 | + public function getCustomField(string $gid) { |
|
| 217 | 217 | return $this->load(CustomField::class, $this, "custom_fields/{$gid}"); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @return User |
| 224 | 224 | */ |
| 225 | - public function getMe () { |
|
| 225 | + public function getMe() { |
|
| 226 | 226 | return $this->getUser('me'); |
| 227 | 227 | } |
| 228 | 228 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @param array $query |
| 234 | 234 | * @return string |
| 235 | 235 | */ |
| 236 | - protected function getPath (string $path, array $query): string { |
|
| 236 | + protected function getPath(string $path, array $query): string { |
|
| 237 | 237 | return $query ? $path . '?' . http_build_query($query) : $path; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @param string $gid |
| 244 | 244 | * @return null|Portfolio |
| 245 | 245 | */ |
| 246 | - public function getPortfolio (string $gid) { |
|
| 246 | + public function getPortfolio(string $gid) { |
|
| 247 | 247 | return $this->load(Portfolio::class, $this, "portfolios/{$gid}"); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * @param string $gid |
| 254 | 254 | * @return null|Project |
| 255 | 255 | */ |
| 256 | - public function getProject (string $gid) { |
|
| 256 | + public function getProject(string $gid) { |
|
| 257 | 257 | return $this->load(Project::class, $this, "projects/{$gid}"); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * @param string $gid |
| 264 | 264 | * @return null|Section |
| 265 | 265 | */ |
| 266 | - public function getSection (string $gid) { |
|
| 266 | + public function getSection(string $gid) { |
|
| 267 | 267 | return $this->load(Section::class, $this, "sections/{$gid}"); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @param string $gid |
| 274 | 274 | * @return null|Story |
| 275 | 275 | */ |
| 276 | - public function getStory (string $gid) { |
|
| 276 | + public function getStory(string $gid) { |
|
| 277 | 277 | return $this->load(Story::class, $this, "stories/{$gid}"); |
| 278 | 278 | } |
| 279 | 279 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | * @param string $gid |
| 284 | 284 | * @return null|Tag |
| 285 | 285 | */ |
| 286 | - public function getTag (string $gid) { |
|
| 286 | + public function getTag(string $gid) { |
|
| 287 | 287 | return $this->load(Tag::class, $this, "tags/{$gid}"); |
| 288 | 288 | } |
| 289 | 289 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * @param string $gid |
| 294 | 294 | * @return null|Task |
| 295 | 295 | */ |
| 296 | - public function getTask (string $gid) { |
|
| 296 | + public function getTask(string $gid) { |
|
| 297 | 297 | return $this->load(Task::class, $this, "tasks/{$gid}"); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * @param string $gid |
| 304 | 304 | * @return null|Team |
| 305 | 305 | */ |
| 306 | - public function getTeam (string $gid) { |
|
| 306 | + public function getTeam(string $gid) { |
|
| 307 | 307 | return $this->load(Team::class, $this, "teams/{$gid}"); |
| 308 | 308 | } |
| 309 | 309 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * @param string $gid |
| 314 | 314 | * @return null|User |
| 315 | 315 | */ |
| 316 | - public function getUser (string $gid) { |
|
| 316 | + public function getUser(string $gid) { |
|
| 317 | 317 | return $this->load(User::class, $this, "users/{$gid}"); |
| 318 | 318 | } |
| 319 | 319 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @param array $data |
| 326 | 326 | * @return ProjectEvent|TaskEvent|StoryEvent |
| 327 | 327 | */ |
| 328 | - public function getWebhookEvent (array $data) { |
|
| 328 | + public function getWebhookEvent(array $data) { |
|
| 329 | 329 | static $classes = [ |
| 330 | 330 | Project::TYPE => ProjectEvent::class, |
| 331 | 331 | Task::TYPE => TaskEvent::class, |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | * @param string $gid |
| 339 | 339 | * @return null|Workspace |
| 340 | 340 | */ |
| 341 | - public function getWorkspace (string $gid) { |
|
| 341 | + public function getWorkspace(string $gid) { |
|
| 342 | 342 | return $this->load(Workspace::class, $this, "workspaces/{$gid}"); |
| 343 | 343 | } |
| 344 | 344 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * @param string $name |
| 347 | 347 | * @return null|Workspace |
| 348 | 348 | */ |
| 349 | - public function getWorkspaceByName (string $name) { |
|
| 349 | + public function getWorkspaceByName(string $name) { |
|
| 350 | 350 | foreach ($this->getMe()->getWorkspaces() as $workspace) { |
| 351 | 351 | if ($workspace->getName() === $name) { |
| 352 | 352 | return $workspace; |
@@ -359,16 +359,16 @@ discard block |
||
| 359 | 359 | * @param string $json |
| 360 | 360 | * @return null|array |
| 361 | 361 | */ |
| 362 | - protected function jsonDecode (string $json) { |
|
| 363 | - return json_decode($json, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 362 | + protected function jsonDecode(string $json) { |
|
| 363 | + return json_decode($json, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | /** |
| 367 | 367 | * @param array $data |
| 368 | 368 | * @return string |
| 369 | 369 | */ |
| 370 | - protected function jsonEncode (array $data): string { |
|
| 371 | - return json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
|
| 370 | + protected function jsonEncode(array $data): string { |
|
| 371 | + return json_encode($data, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | /** |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | * @param array $query |
| 383 | 383 | * @return null|mixed|AbstractEntity |
| 384 | 384 | */ |
| 385 | - public function load (string $class, $caller, string $path, array $query = []) { |
|
| 385 | + public function load(string $class, $caller, string $path, array $query = []) { |
|
| 386 | 386 | $key = $this->getPath($path, $query); |
| 387 | 387 | return $this->getCache()->get($key, $caller, function($caller) use ($class, $path, $query) { |
| 388 | 388 | $data = $this->get($path, $query, ['expand' => 'this']); |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | * @param int $pages If positive, stops after this many pages have been fetched. |
| 403 | 403 | * @return array|AbstractEntity[] |
| 404 | 404 | */ |
| 405 | - public function loadAll (string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
| 405 | + public function loadAll(string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
| 406 | 406 | $query['opt_expand'] = 'this'; |
| 407 | 407 | $query += ['limit' => 100]; |
| 408 | 408 | $path = $this->getPath($path, $query); |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | * @param array $options |
| 429 | 429 | * @return null|array |
| 430 | 430 | */ |
| 431 | - public function post (string $path, array $data = [], array $options = []) { |
|
| 431 | + public function post(string $path, array $data = [], array $options = []) { |
|
| 432 | 432 | $response = $this->exec('POST', $path, [ |
| 433 | 433 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 434 | 434 | CURLOPT_POSTFIELDS => $this->jsonEncode(['options' => $options, 'data' => $data]) |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | * @param array $options |
| 445 | 445 | * @return null|array |
| 446 | 446 | */ |
| 447 | - public function put (string $path, array $data = [], array $options = []) { |
|
| 447 | + public function put(string $path, array $data = [], array $options = []) { |
|
| 448 | 448 | $response = $this->exec('PUT', $path, [ |
| 449 | 449 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 450 | 450 | CURLOPT_POSTFIELDS => $this->jsonEncode(['options' => $options, 'data' => $data]) |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | * @param null|string $token |
| 464 | 464 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
| 465 | 465 | */ |
| 466 | - public function sync ($entity, ?string &$token) { |
|
| 466 | + public function sync($entity, ?string &$token) { |
|
| 467 | 467 | try { |
| 468 | 468 | $response = $this->exec('GET', $this->getPath('events', [ |
| 469 | 469 | 'resource' => $entity->getGid(), |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | * @param string $file |
| 499 | 499 | * @return null|array |
| 500 | 500 | */ |
| 501 | - public function upload (string $path, string $file) { |
|
| 501 | + public function upload(string $path, string $file) { |
|
| 502 | 502 | $response = $this->exec('POST', $path, [ |
| 503 | 503 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
| 504 | 504 | ]); |