@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | 'enum_options' => [EnumOption::class], |
| 41 | 41 | ]; |
| 42 | 42 | |
| 43 | - final public function __toString (): string { |
|
| 43 | + final public function __toString(): string { |
|
| 44 | 44 | return "custom_fields/{$this->getGid()}"; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - final protected function _getDir (): string { |
|
| 47 | + final protected function _getDir(): string { |
|
| 48 | 48 | return 'custom_fields'; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param string $name |
| 57 | 57 | * @return EnumOption |
| 58 | 58 | */ |
| 59 | - public function addEnumOption (string $name) { |
|
| 59 | + public function addEnumOption(string $name) { |
|
| 60 | 60 | /** @var EnumOption $option */ |
| 61 | 61 | $option = $this->api->factory($this, EnumOption::class); |
| 62 | 62 | $option->setName($name); |
@@ -72,35 +72,35 @@ discard block |
||
| 72 | 72 | /** |
| 73 | 73 | * @return bool |
| 74 | 74 | */ |
| 75 | - public function hasNotificationsEnabled (): bool { |
|
| 75 | + public function hasNotificationsEnabled(): bool { |
|
| 76 | 76 | return $this->_is('has_notifications_enabled'); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * @return bool |
| 81 | 81 | */ |
| 82 | - final public function isEnum (): bool { |
|
| 82 | + final public function isEnum(): bool { |
|
| 83 | 83 | return $this->getResourceSubtype() === self::TYPE_ENUM; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * @return bool |
| 88 | 88 | */ |
| 89 | - public function isGlobalToWorkspace (): bool { |
|
| 89 | + public function isGlobalToWorkspace(): bool { |
|
| 90 | 90 | return $this->_is('is_global_to_workspace'); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * @return bool |
| 95 | 95 | */ |
| 96 | - final public function isNumber (): bool { |
|
| 96 | + final public function isNumber(): bool { |
|
| 97 | 97 | return $this->getResourceSubtype() === self::TYPE_NUMBER; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * @return bool |
| 102 | 102 | */ |
| 103 | - final public function isText (): bool { |
|
| 103 | + final public function isText(): bool { |
|
| 104 | 104 | return $this->getResourceSubtype() === self::TYPE_TEXT; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param bool $flag |
| 109 | 109 | * @return $this |
| 110 | 110 | */ |
| 111 | - public function setGlobalToWorkspace (bool $flag) { |
|
| 111 | + public function setGlobalToWorkspace(bool $flag) { |
|
| 112 | 112 | return $this->_set('is_global_to_workspace', $flag); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @param bool $flag |
| 117 | 117 | * @return $this |
| 118 | 118 | */ |
| 119 | - public function setNotificationsEnabled (bool $flag) { |
|
| 119 | + public function setNotificationsEnabled(bool $flag) { |
|
| 120 | 120 | return $this->_set('has_notifications_enabled', $flag); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @param callable $cmp `fn( EnumOption $a, EnumOption $b ): int` |
| 125 | 125 | * @return $this |
| 126 | 126 | */ |
| 127 | - public function sortEnumOptions (callable $cmp) { |
|
| 127 | + public function sortEnumOptions(callable $cmp) { |
|
| 128 | 128 | if ($options = $this->getEnumOptions()) { |
| 129 | 129 | $prev = $options[0]; // first option on remote |
| 130 | 130 | usort($options, $cmp); |
@@ -51,20 +51,20 @@ discard block |
||
| 51 | 51 | * @param Project $project |
| 52 | 52 | * @param array $data |
| 53 | 53 | */ |
| 54 | - public function __construct (Project $project, array $data = []) { |
|
| 54 | + public function __construct(Project $project, array $data = []) { |
|
| 55 | 55 | parent::__construct($project, $data); |
| 56 | 56 | $this->project = $project; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - final public function __toString (): string { |
|
| 59 | + final public function __toString(): string { |
|
| 60 | 60 | return "project_statuses/{$this->getGid()}"; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - final protected function _getDir (): string { |
|
| 63 | + final protected function _getDir(): string { |
|
| 64 | 64 | return "{$this->project}/project_statuses"; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - protected function _setData (array $data): void { |
|
| 67 | + protected function _setData(array $data): void { |
|
| 68 | 68 | // redundant, prefer created_by |
| 69 | 69 | unset($data['author']); |
| 70 | 70 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | /** |
| 75 | 75 | * @return Project |
| 76 | 76 | */ |
| 77 | - public function getProject () { |
|
| 77 | + public function getProject() { |
|
| 78 | 78 | return $this->project; |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | \ No newline at end of file |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $token |
| 49 | 49 | * @param Pool|null $pool |
| 50 | 50 | */ |
| 51 | - public function __construct (string $token, Pool $pool = null) { |
|
| 51 | + public function __construct(string $token, Pool $pool = null) { |
|
| 52 | 52 | $this->token = $token; |
| 53 | 53 | $this->pool = $pool ?? new Pool(); |
| 54 | 54 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @return null|array |
| 63 | 63 | * @internal |
| 64 | 64 | */ |
| 65 | - protected function _exec (string $method, string $path, array $curlOpts = []) { |
|
| 65 | + protected function _exec(string $method, string $path, array $curlOpts = []) { |
|
| 66 | 66 | $log = $this->getLog(); |
| 67 | 67 | $log->log(LOG_DEBUG, "{$method} {$path}", $curlOpts); |
| 68 | 68 | /** @var resource $ch */ |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @return string |
| 114 | 114 | * @internal |
| 115 | 115 | */ |
| 116 | - protected function _getPath (string $path, array $query): string { |
|
| 116 | + protected function _getPath(string $path, array $query): string { |
|
| 117 | 117 | if ($query) { |
| 118 | 118 | return $path . '?' . http_build_query($query); |
| 119 | 119 | } |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * @return array |
| 126 | 126 | * @internal |
| 127 | 127 | */ |
| 128 | - protected function _jsonDecode (string $json) { |
|
| 129 | - return json_decode($json, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 128 | + protected function _jsonDecode(string $json) { |
|
| 129 | + return json_decode($json, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | * @return string |
| 135 | 135 | * @internal |
| 136 | 136 | */ |
| 137 | - protected function _jsonEncode (array $data): string { |
|
| 138 | - return json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR); |
|
| 137 | + protected function _jsonEncode(array $data): string { |
|
| 138 | + return json_encode($data, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @param string $path |
| 145 | 145 | */ |
| 146 | - public function delete (string $path): void { |
|
| 146 | + public function delete(string $path): void { |
|
| 147 | 147 | $this->_exec('DELETE', $path); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param array $data |
| 158 | 158 | * @return mixed|Data|AbstractEntity |
| 159 | 159 | */ |
| 160 | - public function factory ($caller, string $class, array $data = []) { |
|
| 160 | + public function factory($caller, string $class, array $data = []) { |
|
| 161 | 161 | return new $class($caller, $data); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param array $opt |
| 170 | 170 | * @return null|array |
| 171 | 171 | */ |
| 172 | - public function get (string $path, array $query = [], array $opt = []) { |
|
| 172 | + public function get(string $path, array $query = [], array $opt = []) { |
|
| 173 | 173 | foreach ($opt as $name => $value) { |
| 174 | 174 | $query["opt_{$name}"] = $value; |
| 175 | 175 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param string $gid |
| 184 | 184 | * @return null|Attachment |
| 185 | 185 | */ |
| 186 | - public function getAttachment (string $gid) { |
|
| 186 | + public function getAttachment(string $gid) { |
|
| 187 | 187 | return $this->load($this, Attachment::class, "attachments/{$gid}"); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param string $gid |
| 194 | 194 | * @return null|CustomField |
| 195 | 195 | */ |
| 196 | - public function getCustomField (string $gid) { |
|
| 196 | + public function getCustomField(string $gid) { |
|
| 197 | 197 | return $this->load($this, CustomField::class, "custom_fields/{$gid}"); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -203,14 +203,14 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @return Workspace |
| 205 | 205 | */ |
| 206 | - public function getDefaultWorkspace () { |
|
| 206 | + public function getDefaultWorkspace() { |
|
| 207 | 207 | return $this->getMe()->getDefaultWorkspace(); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
| 211 | 211 | * @return LoggerInterface |
| 212 | 212 | */ |
| 213 | - public function getLog () { |
|
| 213 | + public function getLog() { |
|
| 214 | 214 | return $this->log ?? $this->log = new NullLogger(); |
| 215 | 215 | } |
| 216 | 216 | |
@@ -219,14 +219,14 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @return User |
| 221 | 221 | */ |
| 222 | - public function getMe () { |
|
| 222 | + public function getMe() { |
|
| 223 | 223 | return $this->me ?? $this->me = $this->getUser('me'); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * @return Pool |
| 228 | 228 | */ |
| 229 | - final public function getPool () { |
|
| 229 | + final public function getPool() { |
|
| 230 | 230 | return $this->pool; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | * @param string $gid |
| 237 | 237 | * @return null|Portfolio |
| 238 | 238 | */ |
| 239 | - public function getPortfolio (string $gid) { |
|
| 239 | + public function getPortfolio(string $gid) { |
|
| 240 | 240 | return $this->load($this, Portfolio::class, "portfolios/{$gid}"); |
| 241 | 241 | } |
| 242 | 242 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @param string $gid |
| 247 | 247 | * @return null|Project |
| 248 | 248 | */ |
| 249 | - public function getProject (string $gid) { |
|
| 249 | + public function getProject(string $gid) { |
|
| 250 | 250 | return $this->load($this, Project::class, "projects/{$gid}"); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @param string $gid |
| 257 | 257 | * @return null|Section |
| 258 | 258 | */ |
| 259 | - public function getSection (string $gid) { |
|
| 259 | + public function getSection(string $gid) { |
|
| 260 | 260 | return $this->load($this, Section::class, "sections/{$gid}"); |
| 261 | 261 | } |
| 262 | 262 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param string $gid |
| 267 | 267 | * @return null|Story |
| 268 | 268 | */ |
| 269 | - public function getStory (string $gid) { |
|
| 269 | + public function getStory(string $gid) { |
|
| 270 | 270 | return $this->load($this, Story::class, "stories/{$gid}"); |
| 271 | 271 | } |
| 272 | 272 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * @param string $gid |
| 277 | 277 | * @return null|Tag |
| 278 | 278 | */ |
| 279 | - public function getTag (string $gid) { |
|
| 279 | + public function getTag(string $gid) { |
|
| 280 | 280 | return $this->load($this, Tag::class, "tags/{$gid}"); |
| 281 | 281 | } |
| 282 | 282 | |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * @param string $gid |
| 287 | 287 | * @return null|Task |
| 288 | 288 | */ |
| 289 | - public function getTask (string $gid) { |
|
| 289 | + public function getTask(string $gid) { |
|
| 290 | 290 | return $this->load($this, Task::class, "tasks/{$gid}"); |
| 291 | 291 | } |
| 292 | 292 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @param string $gid |
| 297 | 297 | * @return null|TaskList |
| 298 | 298 | */ |
| 299 | - public function getTaskList (string $gid) { |
|
| 299 | + public function getTaskList(string $gid) { |
|
| 300 | 300 | return $this->load($this, TaskList::class, "user_task_lists/{$gid}"); |
| 301 | 301 | } |
| 302 | 302 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @param string $gid |
| 307 | 307 | * @return null|Team |
| 308 | 308 | */ |
| 309 | - public function getTeam (string $gid) { |
|
| 309 | + public function getTeam(string $gid) { |
|
| 310 | 310 | return $this->load($this, Team::class, "teams/{$gid}"); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @param string $gid |
| 317 | 317 | * @return null|User |
| 318 | 318 | */ |
| 319 | - public function getUser (string $gid) { |
|
| 319 | + public function getUser(string $gid) { |
|
| 320 | 320 | return $this->load($this, User::class, "users/{$gid}"); |
| 321 | 321 | } |
| 322 | 322 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | * @param string $gid |
| 325 | 325 | * @return ProjectWebhook|TaskWebhook |
| 326 | 326 | */ |
| 327 | - public function getWebhook (string $gid) { |
|
| 327 | + public function getWebhook(string $gid) { |
|
| 328 | 328 | return $this->pool->get($gid, $this, function() use ($gid) { |
| 329 | 329 | static $classes = [ |
| 330 | 330 | Project::TYPE => ProjectWebhook::class, |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | * @param array $data |
| 346 | 346 | * @return Event |
| 347 | 347 | */ |
| 348 | - public function getWebhookEvent (array $data) { |
|
| 348 | + public function getWebhookEvent(array $data) { |
|
| 349 | 349 | return $this->factory($this, Event::class, $data); |
| 350 | 350 | } |
| 351 | 351 | |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | * @param string $gid |
| 356 | 356 | * @return null|Workspace |
| 357 | 357 | */ |
| 358 | - public function getWorkspace (string $gid) { |
|
| 358 | + public function getWorkspace(string $gid) { |
|
| 359 | 359 | return $this->load($this, Workspace::class, "workspaces/{$gid}"); |
| 360 | 360 | } |
| 361 | 361 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param string $name |
| 366 | 366 | * @return null|Workspace |
| 367 | 367 | */ |
| 368 | - public function getWorkspaceByName (string $name) { |
|
| 368 | + public function getWorkspaceByName(string $name) { |
|
| 369 | 369 | foreach ($this->getWorkspaces() as $workspace) { |
| 370 | 370 | if ($workspace->getName() === $name) { |
| 371 | 371 | return $workspace; |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | * |
| 380 | 380 | * @return Workspace[] |
| 381 | 381 | */ |
| 382 | - public function getWorkspaces () { |
|
| 382 | + public function getWorkspaces() { |
|
| 383 | 383 | return $this->getMe()->getWorkspaces(); |
| 384 | 384 | } |
| 385 | 385 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | * @param array $query |
| 393 | 393 | * @return null|mixed|AbstractEntity |
| 394 | 394 | */ |
| 395 | - public function load ($caller, string $class, string $path, array $query = []) { |
|
| 395 | + public function load($caller, string $class, string $path, array $query = []) { |
|
| 396 | 396 | $key = $this->_getPath($path, $query); |
| 397 | 397 | return $this->pool->get($key, $caller, function($caller) use ($class, $path, $query) { |
| 398 | 398 | if ($data = $this->get($path, $query, ['expand' => 'this'])) { |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * @param array $query |
| 412 | 412 | * @return array|AbstractEntity[] |
| 413 | 413 | */ |
| 414 | - public function loadAll ($caller, string $class, string $path, array $query = []) { |
|
| 414 | + public function loadAll($caller, string $class, string $path, array $query = []) { |
|
| 415 | 415 | return iterator_to_array($this->loadEach(...func_get_args())); |
| 416 | 416 | } |
| 417 | 417 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * @param array $query `limit` can exceed `100` here. Empty `limit` for all pages. |
| 427 | 427 | * @return Generator|AbstractEntity[] |
| 428 | 428 | */ |
| 429 | - public function loadEach ($caller, string $class, string $path, array $query = []) { |
|
| 429 | + public function loadEach($caller, string $class, string $path, array $query = []) { |
|
| 430 | 430 | $query['opt_expand'] = 'this'; |
| 431 | 431 | if (!$i = $query['limit'] ?? 0) { |
| 432 | 432 | $i = PHP_INT_MAX; |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | * @param array $opt |
| 451 | 451 | * @return null|array |
| 452 | 452 | */ |
| 453 | - public function post (string $path, array $data = [], array $opt = []) { |
|
| 453 | + public function post(string $path, array $data = [], array $opt = []) { |
|
| 454 | 454 | $response = $this->_exec('POST', $path, [ |
| 455 | 455 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 456 | 456 | CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $opt, 'data' => $data]) |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | * @param array $opt |
| 467 | 467 | * @return null|array |
| 468 | 468 | */ |
| 469 | - public function put (string $path, array $data = [], array $opt = []) { |
|
| 469 | + public function put(string $path, array $data = [], array $opt = []) { |
|
| 470 | 470 | $response = $this->_exec('PUT', $path, [ |
| 471 | 471 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 472 | 472 | CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $opt, 'data' => $data]) |
@@ -477,14 +477,14 @@ discard block |
||
| 477 | 477 | /** |
| 478 | 478 | * @param LoggerInterface $log |
| 479 | 479 | */ |
| 480 | - public function setLog (LoggerInterface $log) { |
|
| 480 | + public function setLog(LoggerInterface $log) { |
|
| 481 | 481 | $this->log = $log; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
| 485 | 485 | * @param Pool $pool |
| 486 | 486 | */ |
| 487 | - public function setPool (Pool $pool) { |
|
| 487 | + public function setPool(Pool $pool) { |
|
| 488 | 488 | $this->pool = $pool; |
| 489 | 489 | } |
| 490 | 490 | |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | * @param null|string $token Updated to the new token. |
| 502 | 502 | * @return Event[] |
| 503 | 503 | */ |
| 504 | - public function sync (string $gid, ?string &$token) { |
|
| 504 | + public function sync(string $gid, ?string &$token) { |
|
| 505 | 505 | try { |
| 506 | 506 | /** @var array $remote Asana throws 400 for missing entities here. */ |
| 507 | 507 | $remote = $this->_exec('GET', $this->_getPath('events', [ |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | * @param string $to |
| 542 | 542 | * @return null|array |
| 543 | 543 | */ |
| 544 | - public function upload (string $file, string $to) { |
|
| 544 | + public function upload(string $file, string $to) { |
|
| 545 | 545 | $response = $this->_exec('POST', $to, [ |
| 546 | 546 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
| 547 | 547 | ]); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | const NAME = 'asana'; |
| 19 | 19 | |
| 20 | - public function boot () { |
|
| 20 | + public function boot() { |
|
| 21 | 21 | $this->publishes([ |
| 22 | 22 | __DIR__ . '/config/asana.php' => $this->app->configPath('asana.php') |
| 23 | 23 | ]); |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function provides () { |
|
| 33 | + public function provides() { |
|
| 34 | 34 | return [self::NAME]; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function register () { |
|
| 37 | + public function register() { |
|
| 38 | 38 | $this->app->singleton(self::NAME, function(Application $app) { |
| 39 | 39 | $config = $app['config'][self::NAME]; |
| 40 | 40 | $pool = null; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | protected $curlInfo; |
| 22 | 22 | |
| 23 | - public function __construct (int $code, string $message, array $curlInfo) { |
|
| 23 | + public function __construct(int $code, string $message, array $curlInfo) { |
|
| 24 | 24 | parent::__construct($message, $code); |
| 25 | 25 | $this->curlInfo = $curlInfo; |
| 26 | 26 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @return array |
| 30 | 30 | */ |
| 31 | - public function getCurlInfo (): array { |
|
| 31 | + public function getCurlInfo(): array { |
|
| 32 | 32 | return $this->curlInfo; |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @param AbstractEntity $entity |
| 31 | 31 | */ |
| 32 | - protected function _add (AbstractEntity $entity): void { |
|
| 32 | + protected function _add(AbstractEntity $entity): void { |
|
| 33 | 33 | $gid = $entity->getGid(); |
| 34 | 34 | $this->entities[$gid] = $entity; |
| 35 | 35 | $this->gids[$gid] = $gid; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param AbstractEntity $entity |
| 40 | 40 | * @param string[] $keys |
| 41 | 41 | */ |
| 42 | - protected function _addKeys (AbstractEntity $entity, ...$keys): void { |
|
| 42 | + protected function _addKeys(AbstractEntity $entity, ...$keys): void { |
|
| 43 | 43 | $this->gids += array_fill_keys($keys, $entity->getGid()); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param Api|Data $caller For hydration if needed. |
| 49 | 49 | * @return null|AbstractEntity |
| 50 | 50 | */ |
| 51 | - protected function _get (string $key, $caller) { |
|
| 51 | + protected function _get(string $key, $caller) { |
|
| 52 | 52 | if (isset($this->gids[$key])) { |
| 53 | 53 | return $this->entities[$this->gids[$key]]; |
| 54 | 54 | } |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | * @param string $key |
| 63 | 63 | * @return bool |
| 64 | 64 | */ |
| 65 | - protected function _has (string $key): bool { |
|
| 65 | + protected function _has(string $key): bool { |
|
| 66 | 66 | return isset($this->gids[$key]); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @param AbstractEntity $entity |
| 71 | 71 | */ |
| 72 | - final public function add (AbstractEntity $entity): void { |
|
| 72 | + final public function add(AbstractEntity $entity): void { |
|
| 73 | 73 | if (!$entity->isDiff()) { |
| 74 | 74 | $this->_add($entity); |
| 75 | 75 | $this->_addKeys($entity, ...$entity->getPoolKeys()); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param Closure $factory `fn( Api|Data $caller ): null|AbstractEntity` |
| 83 | 83 | * @return null|mixed|AbstractEntity |
| 84 | 84 | */ |
| 85 | - final public function get (string $key, $caller, Closure $factory) { |
|
| 85 | + final public function get(string $key, $caller, Closure $factory) { |
|
| 86 | 86 | /** @var AbstractEntity $entity */ |
| 87 | 87 | if (!$entity = $this->_get($key, $caller) and $entity = $factory($caller)) { |
| 88 | 88 | $gid = $entity->getGid(); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * @param string[] $keys |
| 105 | 105 | */ |
| 106 | - public function remove (array $keys): void { |
|
| 106 | + public function remove(array $keys): void { |
|
| 107 | 107 | foreach ($keys as $key) { |
| 108 | 108 | unset($this->entities[$key]); |
| 109 | 109 | unset($this->gids[$key]); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | 'custom_field' => CustomField::class, |
| 24 | 24 | ]; |
| 25 | 25 | |
| 26 | - protected function _setData (array $data): void { |
|
| 26 | + protected function _setData(array $data): void { |
|
| 27 | 27 | // these are the only fields that matter. |
| 28 | 28 | parent::_setData([ |
| 29 | 29 | 'custom_field' => $data['custom_field'], |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | ]); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - final public function getResourceType (): string { |
|
| 34 | + final public function getResourceType(): string { |
|
| 35 | 35 | return self::TYPE; |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -44,46 +44,46 @@ 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 were deprecated for likes |
| 57 | 57 | unset($data['hearted'], $data['hearts'], $data['num_hearts']); |
| 58 | 58 | |
| 59 | 59 | parent::_setData($data); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - final public function isAssignment (): bool { |
|
| 62 | + final public function isAssignment(): bool { |
|
| 63 | 63 | return $this->getResourceSubtype() === self::TYPE_ASSIGNED; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - final public function isComment (): bool { |
|
| 66 | + final public function isComment(): bool { |
|
| 67 | 67 | return $this->getResourceSubtype() === self::TYPE_COMMENT_ADDED; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - final public function isDueDate (): bool { |
|
| 70 | + final public function isDueDate(): bool { |
|
| 71 | 71 | return $this->getResourceSubtype() === self::TYPE_DUE_DATE_CHANGED; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function isEdited (): bool { |
|
| 74 | + public function isEdited(): bool { |
|
| 75 | 75 | return $this->_is('is_edited'); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function isFromApi (): bool { |
|
| 78 | + public function isFromApi(): bool { |
|
| 79 | 79 | return $this->getSource() === 'api'; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public function isFromWeb (): bool { |
|
| 82 | + public function isFromWeb(): bool { |
|
| 83 | 83 | return $this->getSource() === 'web'; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function isPinned (): bool { |
|
| 86 | + public function isPinned(): bool { |
|
| 87 | 87 | return $this->_is('is_pinned'); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param bool $pinned |
| 92 | 92 | * @return $this |
| 93 | 93 | */ |
| 94 | - public function setPinned (bool $pinned) { |
|
| 94 | + public function setPinned(bool $pinned) { |
|
| 95 | 95 | return $this->_set('is_pinned', $pinned); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | /** |
| 36 | 36 | * @return string |
| 37 | 37 | */ |
| 38 | - public static function random (): string { |
|
| 38 | + public static function random(): string { |
|
| 39 | 39 | try { |
| 40 | 40 | $colors = (new ReflectionClass(self::class))->getConstants(); |
| 41 | 41 | return $colors[array_rand($colors)]; |