@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @param PSR16 $psr |
| 36 | 36 | */ |
| 37 | - public function __construct (PSR16 $psr) { |
|
| 37 | + public function __construct(PSR16 $psr) { |
|
| 38 | 38 | $this->psr = $psr; |
| 39 | 39 | $this->ttl = new DateInterval('PT1H'); |
| 40 | 40 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param string $key |
| 44 | 44 | * @throws InvalidArgumentException |
| 45 | 45 | */ |
| 46 | - protected function _delete (string $key) { |
|
| 46 | + protected function _delete(string $key) { |
|
| 47 | 47 | $this->psr->delete('asana/' . $key); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @return null|string|AbstractEntity |
| 53 | 53 | * @throws InvalidArgumentException |
| 54 | 54 | */ |
| 55 | - protected function _get (string $key) { |
|
| 55 | + protected function _get(string $key) { |
|
| 56 | 56 | return $this->psr->get('asana/' . $key); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @param mixed $value |
| 62 | 62 | * @throws InvalidArgumentException |
| 63 | 63 | */ |
| 64 | - protected function _set (string $key, $value) { |
|
| 64 | + protected function _set(string $key, $value) { |
|
| 65 | 65 | $this->psr->set('asana/' . $key, $value, $this->ttl); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @return bool |
| 71 | 71 | * @throws InvalidArgumentException |
| 72 | 72 | */ |
| 73 | - public function add (AbstractEntity $entity): bool { |
|
| 73 | + public function add(AbstractEntity $entity): bool { |
|
| 74 | 74 | if (parent::add($entity)) { |
| 75 | 75 | $this->_set($entity->getGid(), $entity); |
| 76 | 76 | return true; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param string[] $keys |
| 84 | 84 | * @throws InvalidArgumentException |
| 85 | 85 | */ |
| 86 | - protected function addKeys (string $gid, array $keys): void { |
|
| 86 | + protected function addKeys(string $gid, array $keys): void { |
|
| 87 | 87 | parent::addKeys($gid, $keys); |
| 88 | 88 | // stash gid refs |
| 89 | 89 | foreach ($keys as $key) { |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @return null|AbstractEntity |
| 101 | 101 | * @throws InvalidArgumentException |
| 102 | 102 | */ |
| 103 | - public function get (string $key, $caller, Closure $factory) { |
|
| 103 | + public function get(string $key, $caller, Closure $factory) { |
|
| 104 | 104 | // POOL MISS && CACHE HIT |
| 105 | 105 | if (!isset($this->gids[$key]) and $entity = $this->_get($key)) { |
| 106 | 106 | if ($entity instanceof AbstractEntity) { |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | /** |
| 124 | 124 | * @return DateInterval |
| 125 | 125 | */ |
| 126 | - public function getTtl () { |
|
| 126 | + public function getTtl() { |
|
| 127 | 127 | return $this->ttl; |
| 128 | 128 | } |
| 129 | 129 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param AbstractEntity $entity |
| 132 | 132 | * @throws InvalidArgumentException |
| 133 | 133 | */ |
| 134 | - public function remove (AbstractEntity $entity): void { |
|
| 134 | + public function remove(AbstractEntity $entity): void { |
|
| 135 | 135 | parent::remove($entity); |
| 136 | 136 | foreach ($entity->getCacheKeys() as $key) { |
| 137 | 137 | $this->_delete($key); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param DateInterval $ttl |
| 143 | 143 | * @return $this |
| 144 | 144 | */ |
| 145 | - public function setTtl (DateInterval $ttl) { |
|
| 145 | + public function setTtl(DateInterval $ttl) { |
|
| 146 | 146 | $this->ttl = $ttl; |
| 147 | 147 | return $this; |
| 148 | 148 | } |
@@ -53,25 +53,25 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @return Cache |
| 55 | 55 | */ |
| 56 | - public static function getCache () { |
|
| 56 | + public static function getCache() { |
|
| 57 | 57 | return static::$cache ?? static::$cache = new Cache(); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @return Api |
| 62 | 62 | */ |
| 63 | - public static function getDefault () { |
|
| 63 | + public static function getDefault() { |
|
| 64 | 64 | return self::$default; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * @return LoggerInterface |
| 69 | 69 | */ |
| 70 | - public static function getLogger () { |
|
| 70 | + public static function getLogger() { |
|
| 71 | 71 | return static::$logger |
| 72 | 72 | ?? static::$logger = new class implements LoggerInterface { |
| 73 | 73 | |
| 74 | - public function log (string $message, string $path, array $data = null): void { |
|
| 74 | + public function log(string $message, string $path, array $data = null): void { |
|
| 75 | 75 | // stub |
| 76 | 76 | } |
| 77 | 77 | |
@@ -81,28 +81,28 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * @param Cache $cache |
| 83 | 83 | */ |
| 84 | - public static function setCache (Cache $cache) { |
|
| 84 | + public static function setCache(Cache $cache) { |
|
| 85 | 85 | static::$cache = $cache; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @param Api $default |
| 90 | 90 | */ |
| 91 | - public static function setDefault (Api $default) { |
|
| 91 | + public static function setDefault(Api $default) { |
|
| 92 | 92 | self::$default = $default; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * @param LoggerInterface $logger |
| 97 | 97 | */ |
| 98 | - public static function setLogger (LoggerInterface $logger) { |
|
| 98 | + public static function setLogger(LoggerInterface $logger) { |
|
| 99 | 99 | static::$logger = $logger; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * @param string $token |
| 104 | 104 | */ |
| 105 | - public function __construct (string $token) { |
|
| 105 | + public function __construct(string $token) { |
|
| 106 | 106 | $this->token = $token; |
| 107 | 107 | if (!static::$default) { |
| 108 | 108 | static::$default = $this; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @return null|array |
| 119 | 119 | * @internal |
| 120 | 120 | */ |
| 121 | - protected function _exec (string $method, string $path, array $opts = []) { |
|
| 121 | + protected function _exec(string $method, string $path, array $opts = []) { |
|
| 122 | 122 | static::getLogger()->log($method, $path, $opts); |
| 123 | 123 | /** @var resource $ch */ |
| 124 | 124 | $ch = curl_init(); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @return string |
| 168 | 168 | * @internal |
| 169 | 169 | */ |
| 170 | - protected function _getPath (string $path, array $query): string { |
|
| 170 | + protected function _getPath(string $path, array $query): string { |
|
| 171 | 171 | return $query ? $path . '?' . http_build_query($query) : $path; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | * @return null|array |
| 177 | 177 | * @internal |
| 178 | 178 | */ |
| 179 | - protected function _jsonDecode (string $json) { |
|
| 180 | - return json_decode($json, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 179 | + protected function _jsonDecode(string $json) { |
|
| 180 | + return json_decode($json, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | * @return string |
| 186 | 186 | * @internal |
| 187 | 187 | */ |
| 188 | - protected function _jsonEncode (array $data): string { |
|
| 189 | - return json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
|
| 188 | + protected function _jsonEncode(array $data): string { |
|
| 189 | + return json_encode($data, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @param string $path |
| 196 | 196 | */ |
| 197 | - public function delete (string $path): void { |
|
| 197 | + public function delete(string $path): void { |
|
| 198 | 198 | $this->_exec('DELETE', $path); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @param array $data |
| 209 | 209 | * @return mixed|Data|AbstractEntity |
| 210 | 210 | */ |
| 211 | - public function factory (string $class, $caller, array $data = []) { |
|
| 211 | + public function factory(string $class, $caller, array $data = []) { |
|
| 212 | 212 | return new $class($caller, $data); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @param array $options |
| 221 | 221 | * @return null|array |
| 222 | 222 | */ |
| 223 | - public function get (string $path, array $query = [], array $options = []) { |
|
| 223 | + public function get(string $path, array $query = [], array $options = []) { |
|
| 224 | 224 | foreach ($options as $name => $value) { |
| 225 | 225 | $query["opt_{$name}"] = $value; |
| 226 | 226 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @param string $gid |
| 235 | 235 | * @return null|Attachment |
| 236 | 236 | */ |
| 237 | - public function getAttachment (string $gid) { |
|
| 237 | + public function getAttachment(string $gid) { |
|
| 238 | 238 | return $this->load(Attachment::class, $this, "attachments/{$gid}"); |
| 239 | 239 | } |
| 240 | 240 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param string $gid |
| 245 | 245 | * @return null|CustomField |
| 246 | 246 | */ |
| 247 | - public function getCustomField (string $gid) { |
|
| 247 | + public function getCustomField(string $gid) { |
|
| 248 | 248 | return $this->load(CustomField::class, $this, "custom_fields/{$gid}"); |
| 249 | 249 | } |
| 250 | 250 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @return Workspace |
| 256 | 256 | */ |
| 257 | - public function getDefaultWorkspace () { |
|
| 257 | + public function getDefaultWorkspace() { |
|
| 258 | 258 | return $this->getMe()->getDefaultWorkspace(); |
| 259 | 259 | } |
| 260 | 260 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return User |
| 265 | 265 | */ |
| 266 | - public function getMe () { |
|
| 266 | + public function getMe() { |
|
| 267 | 267 | return $this->getUser('me'); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @param string $gid |
| 274 | 274 | * @return null|Portfolio |
| 275 | 275 | */ |
| 276 | - public function getPortfolio (string $gid) { |
|
| 276 | + public function getPortfolio(string $gid) { |
|
| 277 | 277 | return $this->load(Portfolio::class, $this, "portfolios/{$gid}"); |
| 278 | 278 | } |
| 279 | 279 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | * @param string $gid |
| 284 | 284 | * @return null|Project |
| 285 | 285 | */ |
| 286 | - public function getProject (string $gid) { |
|
| 286 | + public function getProject(string $gid) { |
|
| 287 | 287 | return $this->load(Project::class, $this, "projects/{$gid}"); |
| 288 | 288 | } |
| 289 | 289 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * @param string $gid |
| 294 | 294 | * @return null|Section |
| 295 | 295 | */ |
| 296 | - public function getSection (string $gid) { |
|
| 296 | + public function getSection(string $gid) { |
|
| 297 | 297 | return $this->load(Section::class, $this, "sections/{$gid}"); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * @param string $gid |
| 304 | 304 | * @return null|Story |
| 305 | 305 | */ |
| 306 | - public function getStory (string $gid) { |
|
| 306 | + public function getStory(string $gid) { |
|
| 307 | 307 | return $this->load(Story::class, $this, "stories/{$gid}"); |
| 308 | 308 | } |
| 309 | 309 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * @param string $gid |
| 314 | 314 | * @return null|Tag |
| 315 | 315 | */ |
| 316 | - public function getTag (string $gid) { |
|
| 316 | + public function getTag(string $gid) { |
|
| 317 | 317 | return $this->load(Tag::class, $this, "tags/{$gid}"); |
| 318 | 318 | } |
| 319 | 319 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * @param string $gid |
| 324 | 324 | * @return null|Task |
| 325 | 325 | */ |
| 326 | - public function getTask (string $gid) { |
|
| 326 | + public function getTask(string $gid) { |
|
| 327 | 327 | return $this->load(Task::class, $this, "tasks/{$gid}"); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | * @param string $gid |
| 334 | 334 | * @return null|TaskList |
| 335 | 335 | */ |
| 336 | - public function getTaskList (string $gid) { |
|
| 336 | + public function getTaskList(string $gid) { |
|
| 337 | 337 | return $this->load(TaskList::class, $this, "user_task_lists/{$gid}"); |
| 338 | 338 | } |
| 339 | 339 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @param string $gid |
| 344 | 344 | * @return null|Team |
| 345 | 345 | */ |
| 346 | - public function getTeam (string $gid) { |
|
| 346 | + public function getTeam(string $gid) { |
|
| 347 | 347 | return $this->load(Team::class, $this, "teams/{$gid}"); |
| 348 | 348 | } |
| 349 | 349 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @param string $gid |
| 354 | 354 | * @return null|User |
| 355 | 355 | */ |
| 356 | - public function getUser (string $gid) { |
|
| 356 | + public function getUser(string $gid) { |
|
| 357 | 357 | return $this->load(User::class, $this, "users/{$gid}"); |
| 358 | 358 | } |
| 359 | 359 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param array $data |
| 366 | 366 | * @return ProjectEvent|TaskEvent|StoryEvent |
| 367 | 367 | */ |
| 368 | - public function getWebhookEvent (array $data) { |
|
| 368 | + public function getWebhookEvent(array $data) { |
|
| 369 | 369 | static $classes = [ |
| 370 | 370 | Project::TYPE => ProjectEvent::class, |
| 371 | 371 | Task::TYPE => TaskEvent::class, |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * @param string $gid |
| 381 | 381 | * @return null|Workspace |
| 382 | 382 | */ |
| 383 | - public function getWorkspace (string $gid) { |
|
| 383 | + public function getWorkspace(string $gid) { |
|
| 384 | 384 | return $this->load(Workspace::class, $this, "workspaces/{$gid}"); |
| 385 | 385 | } |
| 386 | 386 | |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * @param string $name |
| 391 | 391 | * @return null|Workspace |
| 392 | 392 | */ |
| 393 | - public function getWorkspaceByName (string $name) { |
|
| 393 | + public function getWorkspaceByName(string $name) { |
|
| 394 | 394 | foreach ($this->getWorkspaces() as $workspace) { |
| 395 | 395 | if ($workspace->getName() === $name) { |
| 396 | 396 | return $workspace; |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * |
| 405 | 405 | * @return Workspace[] |
| 406 | 406 | */ |
| 407 | - public function getWorkspaces () { |
|
| 407 | + public function getWorkspaces() { |
|
| 408 | 408 | return $this->getMe()->getWorkspaces(); |
| 409 | 409 | } |
| 410 | 410 | |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | * @param array $query |
| 420 | 420 | * @return null|mixed|AbstractEntity |
| 421 | 421 | */ |
| 422 | - public function load (string $class, $caller, string $path, array $query = []) { |
|
| 422 | + public function load(string $class, $caller, string $path, array $query = []) { |
|
| 423 | 423 | $key = $this->_getPath($path, $query); |
| 424 | 424 | return $this->getCache()->get($key, $caller, function($caller) use ($class, $path, $query) { |
| 425 | 425 | $data = $this->get($path, $query, ['expand' => 'this']); |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | * @param int $pages If positive, stops after this many pages have been fetched. |
| 440 | 440 | * @return array|AbstractEntity[] |
| 441 | 441 | */ |
| 442 | - public function loadAll (string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
| 442 | + public function loadAll(string $class, $caller, string $path, array $query = [], int $pages = 0) { |
|
| 443 | 443 | $query['opt_expand'] = 'this'; |
| 444 | 444 | $query += ['limit' => 100]; |
| 445 | 445 | $path = $this->_getPath($path, $query); |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | * @param array $options |
| 466 | 466 | * @return null|array |
| 467 | 467 | */ |
| 468 | - public function post (string $path, array $data = [], array $options = []) { |
|
| 468 | + public function post(string $path, array $data = [], array $options = []) { |
|
| 469 | 469 | $response = $this->_exec('POST', $path, [ |
| 470 | 470 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 471 | 471 | CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data]) |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | * @param array $options |
| 482 | 482 | * @return null|array |
| 483 | 483 | */ |
| 484 | - public function put (string $path, array $data = [], array $options = []) { |
|
| 484 | + public function put(string $path, array $data = [], array $options = []) { |
|
| 485 | 485 | $response = $this->_exec('PUT', $path, [ |
| 486 | 486 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 487 | 487 | CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data]) |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | * @param null|string $token |
| 501 | 501 | * @return ProjectEvent[]|TaskEvent[]|StoryEvent[] |
| 502 | 502 | */ |
| 503 | - public function sync ($entity, ?string &$token) { |
|
| 503 | + public function sync($entity, ?string &$token) { |
|
| 504 | 504 | try { |
| 505 | 505 | $response = $this->_exec('GET', $this->_getPath('events', [ |
| 506 | 506 | 'resource' => $entity->getGid(), |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | * @param string $file |
| 536 | 536 | * @return null|array |
| 537 | 537 | */ |
| 538 | - public function upload (string $path, string $file) { |
|
| 538 | + public function upload(string $path, string $file) { |
|
| 539 | 539 | $response = $this->_exec('POST', $path, [ |
| 540 | 540 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
| 541 | 541 | ]); |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | 'memberships' => 'memberships.(project|section)' |
| 96 | 96 | ]; |
| 97 | 97 | |
| 98 | - final public function __toString (): string { |
|
| 98 | + final public function __toString(): string { |
|
| 99 | 99 | return "tasks/{$this->getGid()}"; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - final protected function _getDir (): string { |
|
| 102 | + final protected function _getDir(): string { |
|
| 103 | 103 | return 'tasks'; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - protected function _save (string $dir = null) { |
|
| 106 | + protected function _save(string $dir = null) { |
|
| 107 | 107 | parent::_save($dir); |
| 108 | 108 | // use isset() to avoid has() fetch. |
| 109 | 109 | if (isset($this->data['custom_fields'])) { |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | return $this; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - protected function _setData (array $data): void { |
|
| 118 | + protected function _setData(array $data): void { |
|
| 119 | 119 | // hearts were deprecated for likes |
| 120 | 120 | unset($data['hearted'], $data['hearts']); |
| 121 | 121 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param string $file |
| 133 | 133 | * @return Attachment |
| 134 | 134 | */ |
| 135 | - public function addAttachment (string $file) { |
|
| 135 | + public function addAttachment(string $file) { |
|
| 136 | 136 | /** @var Attachment $attachment */ |
| 137 | 137 | $attachment = $this->factory(Attachment::class, ['parent' => $this]); |
| 138 | 138 | return $attachment->upload($file); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param string $text |
| 145 | 145 | * @return Story |
| 146 | 146 | */ |
| 147 | - public function addComment (string $text) { |
|
| 147 | + public function addComment(string $text) { |
|
| 148 | 148 | return $this->newComment()->setText($text)->create(); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param Task[] $tasks |
| 156 | 156 | * @return $this |
| 157 | 157 | */ |
| 158 | - public function addDependencies (array $tasks) { |
|
| 158 | + public function addDependencies(array $tasks) { |
|
| 159 | 159 | $this->api->post("{$this}/addDependencies", ['dependents' => array_column($tasks, 'gid')]); |
| 160 | 160 | return $this; |
| 161 | 161 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param Task $task |
| 168 | 168 | * @return $this |
| 169 | 169 | */ |
| 170 | - public function addDependency (Task $task) { |
|
| 170 | + public function addDependency(Task $task) { |
|
| 171 | 171 | return $this->addDependencies([$task]); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * @param Task $task |
| 179 | 179 | * @return $this |
| 180 | 180 | */ |
| 181 | - public function addDependent (Task $task) { |
|
| 181 | + public function addDependent(Task $task) { |
|
| 182 | 182 | return $this->addDependents([$task]); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param Task[] $tasks |
| 190 | 190 | * @return $this |
| 191 | 191 | */ |
| 192 | - public function addDependents (array $tasks) { |
|
| 192 | + public function addDependents(array $tasks) { |
|
| 193 | 193 | $this->api->post("{$this}/addDependents", ['dependents' => array_column($tasks, 'gid')]); |
| 194 | 194 | return $this; |
| 195 | 195 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param User $user |
| 201 | 201 | * @return $this |
| 202 | 202 | */ |
| 203 | - public function addFollower (User $user) { |
|
| 203 | + public function addFollower(User $user) { |
|
| 204 | 204 | return $this->addFollowers([$user]); |
| 205 | 205 | } |
| 206 | 206 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * @param User[] $users |
| 213 | 213 | * @return $this |
| 214 | 214 | */ |
| 215 | - public function addFollowers (array $users) { |
|
| 215 | + public function addFollowers(array $users) { |
|
| 216 | 216 | return $this->_addWithPost("{$this}/addFollowers", [ |
| 217 | 217 | 'followers' => array_column($users, 'gid') |
| 218 | 218 | ], 'followers', $users); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * @param Tag $tag |
| 227 | 227 | * @return $this |
| 228 | 228 | */ |
| 229 | - public function addTag (Tag $tag) { |
|
| 229 | + public function addTag(Tag $tag) { |
|
| 230 | 230 | return $this->_addWithPost("{$this}/addTag", [ |
| 231 | 231 | 'tag' => $tag->getGid() |
| 232 | 232 | ], 'tags', [$tag]); |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param Section|null $section |
| 242 | 242 | * @return $this |
| 243 | 243 | */ |
| 244 | - public function addToProject (Project $project, Section $section = null) { |
|
| 244 | + public function addToProject(Project $project, Section $section = null) { |
|
| 245 | 245 | /** @var Membership $membership */ |
| 246 | 246 | $membership = $this->factory(Membership::class) |
| 247 | 247 | ->_set('project', $project) |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @param string $target |
| 257 | 257 | * @return TaskWebhook |
| 258 | 258 | */ |
| 259 | - public function addWebhook (string $target) { |
|
| 259 | + public function addWebhook(string $target) { |
|
| 260 | 260 | /** @var TaskWebhook $webhook */ |
| 261 | 261 | $webhook = $this->factory(TaskWebhook::class); |
| 262 | 262 | return $webhook->create($this, $target); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param string[] $include |
| 273 | 273 | * @return Job |
| 274 | 274 | */ |
| 275 | - public function duplicate (string $name, array $include) { |
|
| 275 | + public function duplicate(string $name, array $include) { |
|
| 276 | 276 | /** @var array $remote */ |
| 277 | 277 | $remote = $this->api->post("{$this}/duplicate", [ |
| 278 | 278 | 'name' => $name, |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * @depends after-create |
| 288 | 288 | * @return Attachment[] |
| 289 | 289 | */ |
| 290 | - public function getAttachments () { |
|
| 290 | + public function getAttachments() { |
|
| 291 | 291 | return $this->loadAll(Attachment::class, "{$this}/attachments"); |
| 292 | 292 | } |
| 293 | 293 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @depends after-create |
| 298 | 298 | * @return Story[] |
| 299 | 299 | */ |
| 300 | - public function getComments () { |
|
| 300 | + public function getComments() { |
|
| 301 | 301 | return $this->selectStories(function(Story $story) { |
| 302 | 302 | return $story->isComment(); |
| 303 | 303 | }); |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * @depends after-create |
| 310 | 310 | * @return Task[] |
| 311 | 311 | */ |
| 312 | - public function getDependencies () { |
|
| 312 | + public function getDependencies() { |
|
| 313 | 313 | return $this->loadAll(self::class, "{$this}/dependencies"); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @depends after-create |
| 320 | 320 | * @return Task[] |
| 321 | 321 | */ |
| 322 | - public function getDependents () { |
|
| 322 | + public function getDependents() { |
|
| 323 | 323 | return $this->loadAll(self::class, "{$this}/dependents"); |
| 324 | 324 | } |
| 325 | 325 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @param null|string $token |
| 331 | 331 | * @return TaskEvent[]|StoryEvent[] |
| 332 | 332 | */ |
| 333 | - public function getEvents (&$token) { |
|
| 333 | + public function getEvents(&$token) { |
|
| 334 | 334 | return $this->api->sync($this, $token); |
| 335 | 335 | } |
| 336 | 336 | |
@@ -342,14 +342,14 @@ discard block |
||
| 342 | 342 | * |
| 343 | 343 | * @return External |
| 344 | 344 | */ |
| 345 | - public function getExternal () { |
|
| 345 | + public function getExternal() { |
|
| 346 | 346 | return $this->_get('external') ?? $this->data['external'] = $this->factory(External::class); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
| 350 | 350 | * @return Project[] |
| 351 | 351 | */ |
| 352 | - public function getProjects () { |
|
| 352 | + public function getProjects() { |
|
| 353 | 353 | return array_map(function(Membership $membership) { |
| 354 | 354 | return $membership->getProject(); |
| 355 | 355 | }, $this->getMemberships()); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * @depends after-create |
| 362 | 362 | * @return Story[] |
| 363 | 363 | */ |
| 364 | - public function getStories () { |
|
| 364 | + public function getStories() { |
|
| 365 | 365 | return $this->loadAll(Story::class, "{$this}/stories"); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * @depends after-create |
| 372 | 372 | * @return Task[] |
| 373 | 373 | */ |
| 374 | - public function getSubTasks () { |
|
| 374 | + public function getSubTasks() { |
|
| 375 | 375 | return $this->loadAll(self::class, "{$this}/subtasks"); |
| 376 | 376 | } |
| 377 | 377 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | * @depends after-create |
| 382 | 382 | * @return string |
| 383 | 383 | */ |
| 384 | - public function getUrl (): string { |
|
| 384 | + public function getUrl(): string { |
|
| 385 | 385 | return "https://app.asana.com/0/0/{$this->getGid()}"; |
| 386 | 386 | } |
| 387 | 387 | |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | * @depends after-create |
| 392 | 392 | * @return TaskWebhook[] |
| 393 | 393 | */ |
| 394 | - public function getWebhooks () { |
|
| 394 | + public function getWebhooks() { |
|
| 395 | 395 | return $this->loadAll(TaskWebhook::class, 'webhooks', [ |
| 396 | 396 | 'workspace' => $this->getWorkspace()->getGid(), |
| 397 | 397 | 'resource' => $this->getGid() |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | /** |
| 402 | 402 | * @return bool |
| 403 | 403 | */ |
| 404 | - public function isRenderedAsSeparator (): bool { |
|
| 404 | + public function isRenderedAsSeparator(): bool { |
|
| 405 | 405 | return $this->_is('is_rendered_as_separator'); |
| 406 | 406 | } |
| 407 | 407 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * @depends after-create |
| 412 | 412 | * @return Story |
| 413 | 413 | */ |
| 414 | - public function newComment () { |
|
| 414 | + public function newComment() { |
|
| 415 | 415 | return $this->factory(Story::class, [ |
| 416 | 416 | 'resource_subtype' => Story::TYPE_COMMENT_ADDED, |
| 417 | 417 | 'target' => $this |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @depends after-create |
| 425 | 425 | * @return Task |
| 426 | 426 | */ |
| 427 | - public function newSubTask () { |
|
| 427 | + public function newSubTask() { |
|
| 428 | 428 | /** @var Task $sub */ |
| 429 | 429 | $sub = $this->factory(self::class); |
| 430 | 430 | return $sub->setParent($this); |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | * @param Task[] $tasks |
| 438 | 438 | * @return $this |
| 439 | 439 | */ |
| 440 | - public function removeDependencies (array $tasks) { |
|
| 440 | + public function removeDependencies(array $tasks) { |
|
| 441 | 441 | $this->api->post("{$this}/removeDependencies", ['dependencies' => array_column($tasks, 'gid')]); |
| 442 | 442 | return $this; |
| 443 | 443 | } |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * @param Task $task |
| 450 | 450 | * @return $this |
| 451 | 451 | */ |
| 452 | - public function removeDependency (Task $task) { |
|
| 452 | + public function removeDependency(Task $task) { |
|
| 453 | 453 | return $this->removeDependencies([$task]); |
| 454 | 454 | } |
| 455 | 455 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | * @param Task $task |
| 461 | 461 | * @return $this |
| 462 | 462 | */ |
| 463 | - public function removeDependent (Task $task) { |
|
| 463 | + public function removeDependent(Task $task) { |
|
| 464 | 464 | return $this->removeDependents([$task]); |
| 465 | 465 | } |
| 466 | 466 | |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | * @param Task[] $tasks |
| 472 | 472 | * @return $this |
| 473 | 473 | */ |
| 474 | - public function removeDependents (array $tasks) { |
|
| 474 | + public function removeDependents(array $tasks) { |
|
| 475 | 475 | $this->api->post("{$this}/removeDependents", ['dependents' => array_column($tasks, 'gid')]); |
| 476 | 476 | return $this; |
| 477 | 477 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | * @param User $user |
| 483 | 483 | * @return $this |
| 484 | 484 | */ |
| 485 | - public function removeFollower (User $user) { |
|
| 485 | + public function removeFollower(User $user) { |
|
| 486 | 486 | return $this->removeFollowers([$user]); |
| 487 | 487 | } |
| 488 | 488 | |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | * @param User[] $users |
| 495 | 495 | * @return $this |
| 496 | 496 | */ |
| 497 | - public function removeFollowers (array $users) { |
|
| 497 | + public function removeFollowers(array $users) { |
|
| 498 | 498 | return $this->_removeWithPost("{$this}/removeFollowers", [ |
| 499 | 499 | 'followers' => array_column($users, 'gid') |
| 500 | 500 | ], 'followers', $users); |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | * @param Project $project |
| 509 | 509 | * @return $this |
| 510 | 510 | */ |
| 511 | - public function removeFromProject (Project $project) { |
|
| 511 | + public function removeFromProject(Project $project) { |
|
| 512 | 512 | return $this->_removeWithPost("{$this}/removeProject", [ |
| 513 | 513 | 'project' => $project->getGid() |
| 514 | 514 | ], 'memberships', function(Membership $membership) use ($project) { |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | * @param Tag $tag |
| 525 | 525 | * @return $this |
| 526 | 526 | */ |
| 527 | - public function removeTag (Tag $tag) { |
|
| 527 | + public function removeTag(Tag $tag) { |
|
| 528 | 528 | return $this->_removeWithPost("{$this}/removeTag", [ |
| 529 | 529 | 'tag' => $tag->getGid() |
| 530 | 530 | ], 'tags', [$tag]); |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | * @param callable $filter `fn( Attachment $attachment): bool` |
| 535 | 535 | * @return Attachment[] |
| 536 | 536 | */ |
| 537 | - public function selectAttachments (callable $filter) { |
|
| 537 | + public function selectAttachments(callable $filter) { |
|
| 538 | 538 | return $this->_select($this->getAttachments(), $filter); |
| 539 | 539 | } |
| 540 | 540 | |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | * @param callable $filter `fn( Story $comment ): bool` |
| 543 | 543 | * @return Story[] |
| 544 | 544 | */ |
| 545 | - public function selectComments (callable $filter) { |
|
| 545 | + public function selectComments(callable $filter) { |
|
| 546 | 546 | return $this->_select($this->getComments(), $filter); |
| 547 | 547 | } |
| 548 | 548 | |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | * @param callable $filter `fn( Task $dependency ): bool` |
| 551 | 551 | * @return Task[] |
| 552 | 552 | */ |
| 553 | - public function selectDependencies (callable $filter) { |
|
| 553 | + public function selectDependencies(callable $filter) { |
|
| 554 | 554 | return $this->_select($this->getDependencies(), $filter); |
| 555 | 555 | } |
| 556 | 556 | |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | * @param callable $filter `fn( Task $dependent ): bool` |
| 559 | 559 | * @return Task[] |
| 560 | 560 | */ |
| 561 | - public function selectDependents (callable $filter) { |
|
| 561 | + public function selectDependents(callable $filter) { |
|
| 562 | 562 | return $this->_select($this->getDependents(), $filter); |
| 563 | 563 | } |
| 564 | 564 | |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | * @param callable $filter `fn( Project $project ): bool` |
| 567 | 567 | * @return Project[] |
| 568 | 568 | */ |
| 569 | - public function selectProjects (callable $filter) { |
|
| 569 | + public function selectProjects(callable $filter) { |
|
| 570 | 570 | return $this->_select($this->getProjects(), $filter); |
| 571 | 571 | } |
| 572 | 572 | |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | * @param callable $filter `fn( Story $story ): bool` |
| 575 | 575 | * @return Story[] |
| 576 | 576 | */ |
| 577 | - public function selectStories (callable $filter) { |
|
| 577 | + public function selectStories(callable $filter) { |
|
| 578 | 578 | return $this->_select($this->getStories(), $filter); |
| 579 | 579 | } |
| 580 | 580 | |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | * @param callable $filter `fn( Task $subtask ): bool` |
| 583 | 583 | * @return Task[] |
| 584 | 584 | */ |
| 585 | - public function selectSubTasks (callable $filter) { |
|
| 585 | + public function selectSubTasks(callable $filter) { |
|
| 586 | 586 | return $this->_select($this->getSubTasks(), $filter); |
| 587 | 587 | } |
| 588 | 588 | |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | * @param null|Task $parent |
| 594 | 594 | * @return $this |
| 595 | 595 | */ |
| 596 | - public function setParent (?self $parent) { |
|
| 596 | + public function setParent(?self $parent) { |
|
| 597 | 597 | return $this->_setWithPost("{$this}/setParent", [ |
| 598 | 598 | 'parent' => $parent |
| 599 | 599 | ], 'parent', $parent); |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | * @param bool $flag |
| 604 | 604 | * @return $this |
| 605 | 605 | */ |
| 606 | - public function setRenderedAsSeparator (bool $flag) { |
|
| 606 | + public function setRenderedAsSeparator(bool $flag) { |
|
| 607 | 607 | return $this->_set('is_rendered_as_separator', $flag); |
| 608 | 608 | } |
| 609 | 609 | |
@@ -18,13 +18,13 @@ |
||
| 18 | 18 | 'user' => User::class |
| 19 | 19 | ]; |
| 20 | 20 | |
| 21 | - protected function _setData (array $data): void { |
|
| 21 | + protected function _setData(array $data): void { |
|
| 22 | 22 | // useless. likes aren't entities. |
| 23 | 23 | unset($data['gid'], $data['resource_type']); |
| 24 | 24 | parent::_setData($data); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - final public function getResourceType (): string { |
|
| 27 | + final public function getResourceType(): string { |
|
| 28 | 28 | return self::TYPE; |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -44,45 +44,45 @@ discard block |
||
| 44 | 44 | 'target' => Task::class |
| 45 | 45 | ]; |
| 46 | 46 | |
| 47 | - final public function __toString (): string { |
|
| 47 | + final public function __toString(): string { |
|
| 48 | 48 | return "stories/{$this->getGid()}"; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - final protected function _getDir (): string { |
|
| 51 | + final protected function _getDir(): string { |
|
| 52 | 52 | return "{$this->getTarget()}/stories"; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - protected function _setData (array $data): void { |
|
| 55 | + protected function _setData(array $data): void { |
|
| 56 | 56 | // hearts are deprecated in favor of likes |
| 57 | 57 | unset($data['hearted'], $data['hearts'], $data['num_hearts']); |
| 58 | 58 | parent::_setData($data); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - final public function isAssignment (): bool { |
|
| 61 | + final public function isAssignment(): bool { |
|
| 62 | 62 | return $this->getResourceSubtype() === self::TYPE_ASSIGNED; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - final public function isComment (): bool { |
|
| 65 | + final public function isComment(): bool { |
|
| 66 | 66 | return $this->getResourceSubtype() === self::TYPE_COMMENT_ADDED; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - final public function isDueDate (): bool { |
|
| 69 | + final public function isDueDate(): bool { |
|
| 70 | 70 | return $this->getResourceSubtype() === self::TYPE_DUE_DATE_CHANGED; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function isEdited (): bool { |
|
| 73 | + public function isEdited(): bool { |
|
| 74 | 74 | return $this->_is('is_edited'); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function isFromApi (): bool { |
|
| 77 | + public function isFromApi(): bool { |
|
| 78 | 78 | return $this->getSource() === 'api'; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function isFromWeb (): bool { |
|
| 81 | + public function isFromWeb(): bool { |
|
| 82 | 82 | return $this->getSource() === 'web'; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function isPinned (): bool { |
|
| 85 | + public function isPinned(): bool { |
|
| 86 | 86 | return $this->_is('is_pinned'); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param bool $pinned |
| 91 | 91 | * @return $this |
| 92 | 92 | */ |
| 93 | - public function setPinned (bool $pinned) { |
|
| 93 | + public function setPinned(bool $pinned) { |
|
| 94 | 94 | return $this->_set('is_pinned', $pinned); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | protected $types = []; |
| 47 | 47 | |
| 48 | - public function __construct (Task $task, array $data = []) { |
|
| 48 | + public function __construct(Task $task, array $data = []) { |
|
| 49 | 49 | $this->task = $task; |
| 50 | 50 | parent::__construct($task, $data); |
| 51 | 51 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @param array $data |
| 57 | 57 | */ |
| 58 | - protected function _setData (array $data): void { |
|
| 58 | + protected function _setData(array $data): void { |
|
| 59 | 59 | $this->index = []; |
| 60 | 60 | $this->optionNames = []; |
| 61 | 61 | $keys = array_flip(['gid', 'name', 'type', 'enum_options', 'enum_value', 'text_value', 'number_value']); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * @return int |
| 79 | 79 | */ |
| 80 | - public function count () { |
|
| 80 | + public function count() { |
|
| 81 | 81 | return count($this->data); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | * @param string $enumGid |
| 86 | 86 | * @return null|string |
| 87 | 87 | */ |
| 88 | - public function getCurrentOptionName (string $enumGid): ?string { |
|
| 88 | + public function getCurrentOptionName(string $enumGid): ?string { |
|
| 89 | 89 | return $this->getOptionName($enumGid, $this[$enumGid]); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function getDiff (): array { |
|
| 92 | + public function getDiff(): array { |
|
| 93 | 93 | $diff = []; |
| 94 | 94 | foreach (array_keys($this->diff) as $index) { |
| 95 | 95 | $gid = $this->index[$index]; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | /** |
| 102 | 102 | * @return Generator |
| 103 | 103 | */ |
| 104 | - public function getIterator () { |
|
| 104 | + public function getIterator() { |
|
| 105 | 105 | foreach (array_keys($this->index) as $gid) { |
| 106 | 106 | yield $gid => $this[$gid]; |
| 107 | 107 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param string $fieldGid |
| 112 | 112 | * @return null|string |
| 113 | 113 | */ |
| 114 | - public function getName (string $fieldGid): ?string { |
|
| 114 | + public function getName(string $fieldGid): ?string { |
|
| 115 | 115 | return $this->data[$this->index[$fieldGid]]['name']; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return string[] |
| 122 | 122 | */ |
| 123 | - public function getNames () { |
|
| 123 | + public function getNames() { |
|
| 124 | 124 | return array_column($this->data, 'name', 'gid'); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @param string $optionGid |
| 130 | 130 | * @return null|string |
| 131 | 131 | */ |
| 132 | - public function getOptionName (string $enumGid, string $optionGid): ?string { |
|
| 132 | + public function getOptionName(string $enumGid, string $optionGid): ?string { |
|
| 133 | 133 | return $this->optionNames[$enumGid][$optionGid]; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param string $enumGid |
| 140 | 140 | * @return string[] |
| 141 | 141 | */ |
| 142 | - public function getOptionNames (string $enumGid) { |
|
| 142 | + public function getOptionNames(string $enumGid) { |
|
| 143 | 143 | return $this->optionNames[$enumGid]; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param string $fieldGid |
| 148 | 148 | * @return null|number|string |
| 149 | 149 | */ |
| 150 | - public function getValue (string $fieldGid) { |
|
| 150 | + public function getValue(string $fieldGid) { |
|
| 151 | 151 | $field = $this->data[$this->index[$fieldGid]]; |
| 152 | 152 | if ($field['type'] === CustomField::TYPE_ENUM) { |
| 153 | 153 | return $field['enum_value']['gid']; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param string $fieldGid |
| 160 | 160 | * @return bool |
| 161 | 161 | */ |
| 162 | - public function offsetExists ($fieldGid) { |
|
| 162 | + public function offsetExists($fieldGid) { |
|
| 163 | 163 | return array_key_exists($this->index[$fieldGid], $this->data); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param string $fieldGid |
| 168 | 168 | * @return null|number|string |
| 169 | 169 | */ |
| 170 | - public function offsetGet ($fieldGid) { |
|
| 170 | + public function offsetGet($fieldGid) { |
|
| 171 | 171 | return $this->getValue($fieldGid); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @param string $fieldGid |
| 176 | 176 | * @param null|number|string $value |
| 177 | 177 | */ |
| 178 | - public function offsetSet ($fieldGid, $value) { |
|
| 178 | + public function offsetSet($fieldGid, $value) { |
|
| 179 | 179 | $this->setValue($fieldGid, $value); |
| 180 | 180 | } |
| 181 | 181 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * |
| 185 | 185 | * @param string $fieldGid |
| 186 | 186 | */ |
| 187 | - public function offsetUnset ($fieldGid) { |
|
| 187 | + public function offsetUnset($fieldGid) { |
|
| 188 | 188 | $this->setValue($fieldGid, null); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param null|number|string $value |
| 194 | 194 | * @return $this |
| 195 | 195 | */ |
| 196 | - public function setValue (string $fieldGid, $value) { |
|
| 196 | + public function setValue(string $fieldGid, $value) { |
|
| 197 | 197 | $i = $this->index[$fieldGid]; |
| 198 | 198 | $type = $this->data[$i]['type']; |
| 199 | 199 | if ($type === CustomField::TYPE_ENUM) { |
@@ -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. |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param array $filter |
| 149 | 149 | * @return Project[] |
| 150 | 150 | */ |
| 151 | - public function getProjects (array $filter = ['archived' => false]) { |
|
| 151 | + public function getProjects(array $filter = ['archived' => false]) { |
|
| 152 | 152 | $filter['workspace'] = $this->getGid(); |
| 153 | 153 | return $this->loadAll(Project::class, 'projects', $filter); |
| 154 | 154 | } |
@@ -156,14 +156,14 @@ discard block |
||
| 156 | 156 | /** |
| 157 | 157 | * @return Tag[] |
| 158 | 158 | */ |
| 159 | - public function getTags () { |
|
| 159 | + public function getTags() { |
|
| 160 | 160 | return $this->loadAll(Tag::class, 'tags', ['workspace' => $this->getGid()]); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | 164 | * @return Team[] |
| 165 | 165 | */ |
| 166 | - public function getTeams () { |
|
| 166 | + public function getTeams() { |
|
| 167 | 167 | return $this->loadAll(Team::class, "organizations/{$this->getGid()}/teams"); |
| 168 | 168 | } |
| 169 | 169 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param string $email |
| 172 | 172 | * @return null|User |
| 173 | 173 | */ |
| 174 | - public function getUserByEmail (string $email) { |
|
| 174 | + public function getUserByEmail(string $email) { |
|
| 175 | 175 | return $this->api->getCache()->get("users/{$email}", $this, function() use ($email) { |
| 176 | 176 | foreach ($this->getUsers() as $user) { |
| 177 | 177 | if ($user->getEmail() === $email) { |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | /** |
| 186 | 186 | * @return User[] |
| 187 | 187 | */ |
| 188 | - public function getUsers () { |
|
| 188 | + public function getUsers() { |
|
| 189 | 189 | return $this->loadAll(User::class, "{$this}/users"); |
| 190 | 190 | } |
| 191 | 191 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @return ProjectWebhook[]|TaskWebhook[] |
| 196 | 196 | */ |
| 197 | - public function getWebhooks () { |
|
| 197 | + public function getWebhooks() { |
|
| 198 | 198 | /** @var array $all */ |
| 199 | 199 | $all = $this->api->get('webhooks', ['workspace' => $this->getGid()], ['expand' => 'this']); |
| 200 | 200 | return array_map(function(array $each) { |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | /** |
| 212 | 212 | * @return bool |
| 213 | 213 | */ |
| 214 | - public function isOrganization (): bool { |
|
| 214 | + public function isOrganization(): bool { |
|
| 215 | 215 | return $this->_is('is_organization'); |
| 216 | 216 | } |
| 217 | 217 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @return CustomField |
| 222 | 222 | */ |
| 223 | - public function newCustomField () { |
|
| 223 | + public function newCustomField() { |
|
| 224 | 224 | /** @var CustomField $field */ |
| 225 | 225 | $field = $this->factory(CustomField::class); |
| 226 | 226 | return $field->setWorkspace($this); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return Portfolio |
| 233 | 233 | */ |
| 234 | - public function newPortfolio () { |
|
| 234 | + public function newPortfolio() { |
|
| 235 | 235 | /** @var Portfolio $portfolio */ |
| 236 | 236 | $portfolio = $this->factory(Portfolio::class); |
| 237 | 237 | return $portfolio->setWorkspace($this); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return Project |
| 244 | 244 | */ |
| 245 | - public function newProject () { |
|
| 245 | + public function newProject() { |
|
| 246 | 246 | /** @var Project $project */ |
| 247 | 247 | $project = $this->factory(Project::class); |
| 248 | 248 | return $project->setWorkspace($this); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @return Tag |
| 255 | 255 | */ |
| 256 | - public function newTag () { |
|
| 256 | + public function newTag() { |
|
| 257 | 257 | /** @var Tag $tag */ |
| 258 | 258 | $tag = $this->factory(Tag::class); |
| 259 | 259 | return $tag->setWorkspace($this); |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @return Task |
| 266 | 266 | */ |
| 267 | - public function newTask () { |
|
| 267 | + public function newTask() { |
|
| 268 | 268 | /** @var Task $task */ |
| 269 | 269 | $task = $this->factory(Task::class); |
| 270 | 270 | return $task->setWorkspace($this); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * @param callable $filter `fn( CustomField $field ): bool` |
| 275 | 275 | * @return CustomField[] |
| 276 | 276 | */ |
| 277 | - public function selectCustomFields (callable $filter) { |
|
| 277 | + public function selectCustomFields(callable $filter) { |
|
| 278 | 278 | return $this->_select($this->getCustomFields(), $filter); |
| 279 | 279 | } |
| 280 | 280 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @param callable $filter `fn( Portfolio $portfolio ): bool` |
| 283 | 283 | * @return Portfolio[] |
| 284 | 284 | */ |
| 285 | - public function selectPortfolios (callable $filter) { |
|
| 285 | + public function selectPortfolios(callable $filter) { |
|
| 286 | 286 | return $this->_select($this->getPortfolios(), $filter); |
| 287 | 287 | } |
| 288 | 288 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param callable $filter `fn( Project $project ): bool` |
| 291 | 291 | * @return Project[] |
| 292 | 292 | */ |
| 293 | - public function selectProjects (callable $filter) { |
|
| 293 | + public function selectProjects(callable $filter) { |
|
| 294 | 294 | return $this->_select($this->getProjects([]), $filter); |
| 295 | 295 | } |
| 296 | 296 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * @param callable $filter `fn( Tag $tag ): bool` |
| 299 | 299 | * @return Tag[] |
| 300 | 300 | */ |
| 301 | - public function selectTags (callable $filter) { |
|
| 301 | + public function selectTags(callable $filter) { |
|
| 302 | 302 | return $this->_select($this->getTags(), $filter); |
| 303 | 303 | } |
| 304 | 304 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @param callable $filter `fn( Team $team ): bool` |
| 307 | 307 | * @return Team[] |
| 308 | 308 | */ |
| 309 | - public function selectTeams (callable $filter) { |
|
| 309 | + public function selectTeams(callable $filter) { |
|
| 310 | 310 | return $this->_select($this->getTeams(), $filter); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * @param callable $filter |
| 315 | 315 | * @return User[] |
| 316 | 316 | */ |
| 317 | - public function selectUsers (callable $filter) { |
|
| 317 | + public function selectUsers(callable $filter) { |
|
| 318 | 318 | return $this->_select($this->getUsers(), $filter); |
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | 'custom_field' => CustomField::class, |
| 20 | 20 | ]; |
| 21 | 21 | |
| 22 | - protected function _setData (array $data): void { |
|
| 22 | + protected function _setData(array $data): void { |
|
| 23 | 23 | // useless, settings aren't entities |
| 24 | 24 | unset($data['gid'], $data['resource_type']); |
| 25 | 25 | // deprecated |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | parent::_setData($data); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - final public function getResourceType (): string { |
|
| 32 | + final public function getResourceType(): string { |
|
| 33 | 33 | return self::TYPE; |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @return CustomField[] |
| 17 | 17 | */ |
| 18 | - public function getCustomFields () { |
|
| 18 | + public function getCustomFields() { |
|
| 19 | 19 | return array_map(function(FieldSetting $setting) { |
| 20 | 20 | return $setting->getCustomField(); |
| 21 | 21 | }, $this->getCustomFieldSettings()); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param callable $filter `fn( CustomField $field ): bool` |
| 26 | 26 | * @return CustomField[] |
| 27 | 27 | */ |
| 28 | - public function selectCustomFields (callable $filter) { |
|
| 28 | + public function selectCustomFields(callable $filter) { |
|
| 29 | 29 | return $this->{'_select'}($this->getCustomFields(), $filter); |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |