@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param string $token |
| 44 | 44 | * @param null|Pool $pool |
| 45 | 45 | */ |
| 46 | - public function __construct (string $token, Pool $pool = null) { |
|
| 46 | + public function __construct(string $token, Pool $pool = null) { |
|
| 47 | 47 | $this->token = $token; |
| 48 | 48 | $this->pool = $pool ?? new Pool(); |
| 49 | 49 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @return null|array |
| 58 | 58 | * @internal |
| 59 | 59 | */ |
| 60 | - protected function _exec (string $method, string $path, array $curlOpts = []) { |
|
| 60 | + protected function _exec(string $method, string $path, array $curlOpts = []) { |
|
| 61 | 61 | $log = $this->getLog(); |
| 62 | 62 | $log->log(LOG_DEBUG, "{$method} {$path}", $curlOpts); |
| 63 | 63 | /** @var resource $ch */ |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | switch ($curlInfo['http_code']) { |
| 89 | 89 | case 200: |
| 90 | 90 | case 201: |
| 91 | - return json_decode($body, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 91 | + return json_decode($body, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 92 | 92 | case 404: |
| 93 | 93 | return null; |
| 94 | 94 | case 429: |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @param string $path |
| 109 | 109 | */ |
| 110 | - public function delete (string $path): void { |
|
| 110 | + public function delete(string $path): void { |
|
| 111 | 111 | $this->_exec('DELETE', $path); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param array $data |
| 122 | 122 | * @return mixed|Data|AbstractEntity |
| 123 | 123 | */ |
| 124 | - public function factory ($caller, string $class, array $data = []) { |
|
| 124 | + public function factory($caller, string $class, array $data = []) { |
|
| 125 | 125 | return new $class($caller, $data); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param array $opt |
| 134 | 134 | * @return null|array |
| 135 | 135 | */ |
| 136 | - public function get (string $path, array $query = [], array $opt = []) { |
|
| 136 | + public function get(string $path, array $query = [], array $opt = []) { |
|
| 137 | 137 | foreach ($opt as $name => $value) { |
| 138 | 138 | $query["opt_{$name}"] = $value; |
| 139 | 139 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param string $gid |
| 148 | 148 | * @return null|Attachment |
| 149 | 149 | */ |
| 150 | - public function getAttachment (string $gid) { |
|
| 150 | + public function getAttachment(string $gid) { |
|
| 151 | 151 | return $this->load($this, Attachment::class, "attachments/{$gid}"); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $gid |
| 158 | 158 | * @return null|CustomField |
| 159 | 159 | */ |
| 160 | - public function getCustomField (string $gid) { |
|
| 160 | + public function getCustomField(string $gid) { |
|
| 161 | 161 | return $this->load($this, CustomField::class, "custom_fields/{$gid}"); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -168,28 +168,28 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return Workspace |
| 170 | 170 | */ |
| 171 | - public function getDefaultWorkspace () { |
|
| 171 | + public function getDefaultWorkspace() { |
|
| 172 | 172 | return $this->getMe()->getDefaultWorkspace(); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | 176 | * @return LoggerInterface |
| 177 | 177 | */ |
| 178 | - public function getLog () { |
|
| 178 | + public function getLog() { |
|
| 179 | 179 | return $this->log ?? $this->log = new NullLogger(); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | 183 | * @return User |
| 184 | 184 | */ |
| 185 | - public function getMe () { |
|
| 185 | + public function getMe() { |
|
| 186 | 186 | return $this->getUser('me'); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * @return Pool |
| 191 | 191 | */ |
| 192 | - public function getPool () { |
|
| 192 | + public function getPool() { |
|
| 193 | 193 | return $this->pool; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @param string $gid |
| 200 | 200 | * @return null|Portfolio |
| 201 | 201 | */ |
| 202 | - public function getPortfolio (string $gid) { |
|
| 202 | + public function getPortfolio(string $gid) { |
|
| 203 | 203 | return $this->load($this, Portfolio::class, "portfolios/{$gid}"); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @param string $gid |
| 210 | 210 | * @return null|Project |
| 211 | 211 | */ |
| 212 | - public function getProject (string $gid) { |
|
| 212 | + public function getProject(string $gid) { |
|
| 213 | 213 | return $this->load($this, Project::class, "projects/{$gid}"); |
| 214 | 214 | } |
| 215 | 215 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * @param string $gid |
| 220 | 220 | * @return null|Section |
| 221 | 221 | */ |
| 222 | - public function getSection (string $gid) { |
|
| 222 | + public function getSection(string $gid) { |
|
| 223 | 223 | return $this->load($this, Section::class, "sections/{$gid}"); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param string $gid |
| 230 | 230 | * @return null|Story |
| 231 | 231 | */ |
| 232 | - public function getStory (string $gid) { |
|
| 232 | + public function getStory(string $gid) { |
|
| 233 | 233 | return $this->load($this, Story::class, "stories/{$gid}"); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param string $gid |
| 240 | 240 | * @return null|Tag |
| 241 | 241 | */ |
| 242 | - public function getTag (string $gid) { |
|
| 242 | + public function getTag(string $gid) { |
|
| 243 | 243 | return $this->load($this, Tag::class, "tags/{$gid}"); |
| 244 | 244 | } |
| 245 | 245 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @param string $gid |
| 250 | 250 | * @return null|Task |
| 251 | 251 | */ |
| 252 | - public function getTask (string $gid) { |
|
| 252 | + public function getTask(string $gid) { |
|
| 253 | 253 | return $this->load($this, Task::class, "tasks/{$gid}"); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @param string $gid |
| 260 | 260 | * @return null|TaskList |
| 261 | 261 | */ |
| 262 | - public function getTaskList (string $gid) { |
|
| 262 | + public function getTaskList(string $gid) { |
|
| 263 | 263 | return $this->load($this, TaskList::class, "user_task_lists/{$gid}"); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @param string $gid |
| 270 | 270 | * @return null|Team |
| 271 | 271 | */ |
| 272 | - public function getTeam (string $gid) { |
|
| 272 | + public function getTeam(string $gid) { |
|
| 273 | 273 | return $this->load($this, Team::class, "teams/{$gid}"); |
| 274 | 274 | } |
| 275 | 275 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * @param string $gid |
| 280 | 280 | * @return null|User |
| 281 | 281 | */ |
| 282 | - public function getUser (string $gid) { |
|
| 282 | + public function getUser(string $gid) { |
|
| 283 | 283 | return $this->load($this, User::class, "users/{$gid}"); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * @param string $gid |
| 288 | 288 | * @return ProjectWebhook|TaskWebhook |
| 289 | 289 | */ |
| 290 | - public function getWebhook (string $gid) { |
|
| 290 | + public function getWebhook(string $gid) { |
|
| 291 | 291 | return $this->pool->get($gid, $this, function() use ($gid) { |
| 292 | 292 | static $classes = [ |
| 293 | 293 | Project::TYPE => ProjectWebhook::class, |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @param array $data |
| 309 | 309 | * @return Event |
| 310 | 310 | */ |
| 311 | - public function getWebhookEvent (array $data) { |
|
| 311 | + public function getWebhookEvent(array $data) { |
|
| 312 | 312 | return $this->factory($this, Event::class, $data); |
| 313 | 313 | } |
| 314 | 314 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * @param string $gid |
| 319 | 319 | * @return null|Workspace |
| 320 | 320 | */ |
| 321 | - public function getWorkspace (string $gid) { |
|
| 321 | + public function getWorkspace(string $gid) { |
|
| 322 | 322 | return $this->load($this, Workspace::class, "workspaces/{$gid}"); |
| 323 | 323 | } |
| 324 | 324 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @param array $query |
| 332 | 332 | * @return null|mixed|AbstractEntity |
| 333 | 333 | */ |
| 334 | - public function load ($caller, string $class, string $path, array $query = []) { |
|
| 334 | + public function load($caller, string $class, string $path, array $query = []) { |
|
| 335 | 335 | $key = rtrim($path . '?' . http_build_query($query), '?'); |
| 336 | 336 | return $this->pool->get($key, $caller, function($caller) use ($class, $path, $query) { |
| 337 | 337 | if ($data = $this->get($path, $query, ['expand' => 'this'])) { |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @param array $query |
| 351 | 351 | * @return array|AbstractEntity[] |
| 352 | 352 | */ |
| 353 | - public function loadAll ($caller, string $class, string $path, array $query = []) { |
|
| 353 | + public function loadAll($caller, string $class, string $path, array $query = []) { |
|
| 354 | 354 | return iterator_to_array($this->loadEach(...func_get_args())); |
| 355 | 355 | } |
| 356 | 356 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param array $query `limit` can exceed `100` here. |
| 366 | 366 | * @return Generator|AbstractEntity[] |
| 367 | 367 | */ |
| 368 | - public function loadEach ($caller, string $class, string $path, array $query = []) { |
|
| 368 | + public function loadEach($caller, string $class, string $path, array $query = []) { |
|
| 369 | 369 | $query['opt_expand'] = 'this'; |
| 370 | 370 | $remain = $query['limit'] ?? PHP_INT_MAX; |
| 371 | 371 | do { |
@@ -389,13 +389,13 @@ discard block |
||
| 389 | 389 | * @param array $opt |
| 390 | 390 | * @return null|array |
| 391 | 391 | */ |
| 392 | - public function post (string $path, array $data = [], array $opt = []) { |
|
| 392 | + public function post(string $path, array $data = [], array $opt = []) { |
|
| 393 | 393 | $response = $this->_exec('POST', $path, [ |
| 394 | 394 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 395 | 395 | CURLOPT_POSTFIELDS => json_encode([ |
| 396 | 396 | 'options' => $opt, |
| 397 | 397 | 'data' => $data |
| 398 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
| 398 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
| 399 | 399 | ]); |
| 400 | 400 | return $response['data'] ?? null; |
| 401 | 401 | } |
@@ -408,13 +408,13 @@ discard block |
||
| 408 | 408 | * @param array $opt |
| 409 | 409 | * @return null|array |
| 410 | 410 | */ |
| 411 | - public function put (string $path, array $data = [], array $opt = []) { |
|
| 411 | + public function put(string $path, array $data = [], array $opt = []) { |
|
| 412 | 412 | $response = $this->_exec('PUT', $path, [ |
| 413 | 413 | CURLOPT_HTTPHEADER => ['Content-Type: application/json'], |
| 414 | 414 | CURLOPT_POSTFIELDS => json_encode([ |
| 415 | 415 | 'options' => $opt, |
| 416 | 416 | 'data' => $data |
| 417 | - ], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) |
|
| 417 | + ], JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR) |
|
| 418 | 418 | ]); |
| 419 | 419 | return $response['data'] ?? null; |
| 420 | 420 | } |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | /** |
| 423 | 423 | * @param LoggerInterface $log |
| 424 | 424 | */ |
| 425 | - public function setLog (LoggerInterface $log) { |
|
| 425 | + public function setLog(LoggerInterface $log) { |
|
| 426 | 426 | $this->log = $log; |
| 427 | 427 | } |
| 428 | 428 | |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | * @param null|string $token Updated to the new token. |
| 439 | 439 | * @return Event[] |
| 440 | 440 | */ |
| 441 | - public function sync (string $gid, ?string &$token) { |
|
| 441 | + public function sync(string $gid, ?string &$token) { |
|
| 442 | 442 | try { |
| 443 | 443 | /** @var array $remote Asana throws 400 for missing entities. */ |
| 444 | 444 | $remote = $this->_exec('GET', 'events?' . http_build_query([ |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | } |
| 450 | 450 | catch (AsanaError $error) { |
| 451 | 451 | if ($error->getCode() === 412) { |
| 452 | - $remote = json_decode($error->getMessage(), true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR); |
|
| 452 | + $remote = json_decode($error->getMessage(), true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR); |
|
| 453 | 453 | if (!isset($token)) { |
| 454 | 454 | // API docs say: "The response will be the same as for an expired sync token." |
| 455 | 455 | // The caller knowingly gave a null token, so we don't need to rethrow. |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @param string $to |
| 479 | 479 | * @return array |
| 480 | 480 | */ |
| 481 | - public function upload (string $file, string $to) { |
|
| 481 | + public function upload(string $file, string $to) { |
|
| 482 | 482 | return $this->_exec('POST', $to, [ |
| 483 | 483 | CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data |
| 484 | 484 | ])['data']; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param Project $project |
| 51 | 51 | * @param array $data |
| 52 | 52 | */ |
| 53 | - public function __construct (Project $project, array $data = []) { |
|
| 53 | + public function __construct(Project $project, array $data = []) { |
|
| 54 | 54 | $this->project = $project; |
| 55 | 55 | parent::__construct($project, $data); |
| 56 | 56 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - final public function __toString (): string { |
|
| 63 | + final public function __toString(): string { |
|
| 64 | 64 | return "project_statuses/{$this->getGid()}"; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return string |
| 71 | 71 | */ |
| 72 | - final protected function _getDir (): string { |
|
| 72 | + final protected function _getDir(): string { |
|
| 73 | 73 | return "{$this->project}/project_statuses"; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - protected function _setData (array $data): void { |
|
| 76 | + protected function _setData(array $data): void { |
|
| 77 | 77 | // redundant, prefer created_by |
| 78 | 78 | unset($data['author']); |
| 79 | 79 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * @return Project |
| 85 | 85 | */ |
| 86 | - public function getProject () { |
|
| 86 | + public function getProject() { |
|
| 87 | 87 | return $this->project; |
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | \ No newline at end of file |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return string |
| 38 | 38 | */ |
| 39 | - final public function __toString (): string { |
|
| 39 | + final public function __toString(): string { |
|
| 40 | 40 | return "sections/{$this->getGid()}"; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return string |
| 47 | 47 | */ |
| 48 | - final protected function _getDir (): string { |
|
| 48 | + final protected function _getDir(): string { |
|
| 49 | 49 | return "{$this->getProject()}/sections"; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param array $filter |
| 54 | 54 | * @return Traversable|Task[] |
| 55 | 55 | */ |
| 56 | - public function getIterator (array $filter = Task::GET_INCOMPLETE) { |
|
| 56 | + public function getIterator(array $filter = Task::GET_INCOMPLETE) { |
|
| 57 | 57 | $filter['section'] = $this->getGid(); |
| 58 | 58 | return $this->api->loadEach($this, Task::class, 'tasks', $filter); |
| 59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param array $filter |
| 63 | 63 | * @return Task[] |
| 64 | 64 | */ |
| 65 | - public function getTasks (array $filter = Task::GET_INCOMPLETE) { |
|
| 65 | + public function getTasks(array $filter = Task::GET_INCOMPLETE) { |
|
| 66 | 66 | return iterator_to_array($this->getIterator($filter)); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @depends after-create |
| 73 | 73 | * @return Task |
| 74 | 74 | */ |
| 75 | - public function newTask () { |
|
| 75 | + public function newTask() { |
|
| 76 | 76 | /** @var Task $task */ |
| 77 | 77 | $task = $this->api->factory($this, Task::class); |
| 78 | 78 | return $task->addToProject($this); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | - final public function __toString (): string { |
|
| 51 | + final public function __toString(): string { |
|
| 52 | 52 | return "custom_fields/{$this->getGid()}"; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return string |
| 59 | 59 | */ |
| 60 | - final protected function _getDir (): string { |
|
| 60 | + final protected function _getDir(): string { |
|
| 61 | 61 | return 'custom_fields'; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - protected function _setData (array $data): void { |
|
| 64 | + protected function _setData(array $data): void { |
|
| 65 | 65 | // strip out field entry values if present. |
| 66 | 66 | $data = array_intersect_key($data, array_flip([ |
| 67 | 67 | 'gid', |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param string $name |
| 83 | 83 | * @return EnumOption |
| 84 | 84 | */ |
| 85 | - public function addEnumOption (string $name) { |
|
| 85 | + public function addEnumOption(string $name) { |
|
| 86 | 86 | /** @var EnumOption $option */ |
| 87 | 87 | $option = $this->api->factory($this, EnumOption::class); |
| 88 | 88 | $option->setName($name); |
@@ -98,35 +98,35 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * @return bool |
| 100 | 100 | */ |
| 101 | - final public function hasNotificationsEnabled (): bool { |
|
| 101 | + final public function hasNotificationsEnabled(): bool { |
|
| 102 | 102 | return $this->_is('has_notifications_enabled'); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * @return bool |
| 107 | 107 | */ |
| 108 | - final public function isEnum (): bool { |
|
| 108 | + final public function isEnum(): bool { |
|
| 109 | 109 | return $this->getResourceSubtype() === self::TYPE_ENUM; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * @return bool |
| 114 | 114 | */ |
| 115 | - final public function isGlobalToWorkspace (): bool { |
|
| 115 | + final public function isGlobalToWorkspace(): bool { |
|
| 116 | 116 | return $this->_is('is_global_to_workspace'); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * @return bool |
| 121 | 121 | */ |
| 122 | - final public function isNumber (): bool { |
|
| 122 | + final public function isNumber(): bool { |
|
| 123 | 123 | return $this->getResourceSubtype() === self::TYPE_NUMBER; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * @return bool |
| 128 | 128 | */ |
| 129 | - final public function isText (): bool { |
|
| 129 | + final public function isText(): bool { |
|
| 130 | 130 | return $this->getResourceSubtype() === self::TYPE_TEXT; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param bool $flag |
| 135 | 135 | * @return $this |
| 136 | 136 | */ |
| 137 | - final public function setGlobalToWorkspace (bool $flag) { |
|
| 137 | + final public function setGlobalToWorkspace(bool $flag) { |
|
| 138 | 138 | return $this->_set('is_global_to_workspace', $flag); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param bool $flag |
| 143 | 143 | * @return $this |
| 144 | 144 | */ |
| 145 | - final public function setNotificationsEnabled (bool $flag) { |
|
| 145 | + final public function setNotificationsEnabled(bool $flag) { |
|
| 146 | 146 | return $this->_set('has_notifications_enabled', $flag); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @param callable $cmp `fn( EnumOption $a, EnumOption $b ): int` |
| 151 | 151 | * @return $this |
| 152 | 152 | */ |
| 153 | - public function sortEnumOptions (callable $cmp) { |
|
| 153 | + public function sortEnumOptions(callable $cmp) { |
|
| 154 | 154 | if ($options = $this->getEnumOptions()) { |
| 155 | 155 | $prev = $options[0]; // first option on remote |
| 156 | 156 | usort($options, $cmp); |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * @param Workspace $workspace |
| 21 | 21 | * @return $this |
| 22 | 22 | */ |
| 23 | - final public function setWorkspace (Workspace $workspace) { |
|
| 23 | + final public function setWorkspace(Workspace $workspace) { |
|
| 24 | 24 | return $this->_set('workspace', $workspace); |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return string |
| 40 | 40 | */ |
| 41 | - final public function __toString (): string { |
|
| 41 | + final public function __toString(): string { |
|
| 42 | 42 | return "organization_exports/{$this->getGid()}"; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @return string |
| 49 | 49 | */ |
| 50 | - final protected function _getDir (): string { |
|
| 50 | + final protected function _getDir(): string { |
|
| 51 | 51 | return "organization_exports"; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @param Workspace $organization |
| 56 | 56 | * @return $this |
| 57 | 57 | */ |
| 58 | - public function create (Workspace $organization) { |
|
| 58 | + public function create(Workspace $organization) { |
|
| 59 | 59 | $this->_set('organization', $organization); |
| 60 | 60 | return $this->_create(); |
| 61 | 61 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @return bool |
| 67 | 67 | */ |
| 68 | - final public function isActive (): bool { |
|
| 68 | + final public function isActive(): bool { |
|
| 69 | 69 | return $this->getState() === self::STATE_ACTIVE; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return bool |
| 76 | 76 | */ |
| 77 | - final public function isDone (): bool { |
|
| 77 | + final public function isDone(): bool { |
|
| 78 | 78 | return $this->isSuccessful() or $this->isFailed(); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return bool |
| 85 | 85 | */ |
| 86 | - final public function isFailed (): bool { |
|
| 86 | + final public function isFailed(): bool { |
|
| 87 | 87 | return $this->getState() === self::STATE_FAIL; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return bool |
| 94 | 94 | */ |
| 95 | - final public function isQueued (): bool { |
|
| 95 | + final public function isQueued(): bool { |
|
| 96 | 96 | return $this->getState() === self::STATE_QUEUED; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return bool |
| 103 | 103 | */ |
| 104 | - final public function isSuccessful (): bool { |
|
| 104 | + final public function isSuccessful(): bool { |
|
| 105 | 105 | return $this->getState() === self::STATE_SUCCESS; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @param callable $spinner `fn( OrganizationExport $this ): void` |
| 114 | 114 | * @return $this |
| 115 | 115 | */ |
| 116 | - public function wait (callable $spinner = null) { |
|
| 116 | + public function wait(callable $spinner = null) { |
|
| 117 | 117 | while (!$this->isDone()) { |
| 118 | 118 | if ($spinner) { |
| 119 | 119 | call_user_func($spinner, $this); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | protected $key; |
| 42 | 42 | |
| 43 | - protected function _setData (array $data): void { |
|
| 43 | + protected function _setData(array $data): void { |
|
| 44 | 44 | $this->key = [ |
| 45 | 45 | Event::ACTION_ADDED => 'added_value', |
| 46 | 46 | Event::ACTION_REMOVED => 'removed_value', |
@@ -67,35 +67,35 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return null|User|Project|Section|Task|FieldEntry|Attachment|Story|Like |
| 69 | 69 | */ |
| 70 | - public function getPayload () { |
|
| 70 | + public function getPayload() { |
|
| 71 | 71 | return $this->data[$this->key]; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @return bool |
| 76 | 76 | */ |
| 77 | - final public function hasPayload (): bool { |
|
| 77 | + final public function hasPayload(): bool { |
|
| 78 | 78 | return isset($this->data[$this->key]); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * @return bool |
| 83 | 83 | */ |
| 84 | - final public function wasAddition (): bool { |
|
| 84 | + final public function wasAddition(): bool { |
|
| 85 | 85 | return $this->getAction() === Event::ACTION_ADDED; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @return bool |
| 90 | 90 | */ |
| 91 | - final public function wasRemoval (): bool { |
|
| 91 | + final public function wasRemoval(): bool { |
|
| 92 | 92 | return $this->getAction() === Event::ACTION_REMOVED; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * @return bool |
| 97 | 97 | */ |
| 98 | - final public function wasValue (): bool { |
|
| 98 | + final public function wasValue(): bool { |
|
| 99 | 99 | return $this->getAction() === Event::ACTION_CHANGED; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - final public function __toString (): string { |
|
| 33 | + final public function __toString(): string { |
|
| 34 | 34 | return "teams/{$this->getGid()}"; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param User $user |
| 39 | 39 | * @return $this |
| 40 | 40 | */ |
| 41 | - public function addUser (User $user) { |
|
| 41 | + public function addUser(User $user) { |
|
| 42 | 42 | $this->api->post("{$this}/addUser", ['user' => $user->getGid()]); |
| 43 | 43 | return $this; |
| 44 | 44 | } |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | * @param array $filter |
| 52 | 52 | * @return Project[] |
| 53 | 53 | */ |
| 54 | - public function getProjects (array $filter = Project::GET_ACTIVE) { |
|
| 54 | + public function getProjects(array $filter = Project::GET_ACTIVE) { |
|
| 55 | 55 | return $this->api->loadAll($this, Project::class, "{$this}/projects", $filter); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function getUrl (): string { |
|
| 58 | + public function getUrl(): string { |
|
| 59 | 59 | return "https://app.asana.com/0/{$this->getGid()}/overview"; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return User[] |
| 68 | 68 | */ |
| 69 | - public function getUsers () { |
|
| 69 | + public function getUsers() { |
|
| 70 | 70 | return $this->api->loadAll($this, User::class, "{$this}/users"); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param User $user |
| 75 | 75 | * @return $this |
| 76 | 76 | */ |
| 77 | - public function removeUser (User $user) { |
|
| 77 | + public function removeUser(User $user) { |
|
| 78 | 78 | $this->api->post("{$this}/removeUser", ['user' => $user->getGid()]); |
| 79 | 79 | return $this; |
| 80 | 80 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return string |
| 45 | 45 | */ |
| 46 | - final public function __toString (): string { |
|
| 46 | + final public function __toString(): string { |
|
| 47 | 47 | return "tags/{$this->getGid()}"; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | - final protected function _getDir (): string { |
|
| 55 | + final protected function _getDir(): string { |
|
| 56 | 56 | return 'tags'; |
| 57 | 57 | } |
| 58 | 58 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param array $filter |
| 61 | 61 | * @return Traversable|Task[] |
| 62 | 62 | */ |
| 63 | - public function getIterator (array $filter = Task::GET_INCOMPLETE) { |
|
| 63 | + public function getIterator(array $filter = Task::GET_INCOMPLETE) { |
|
| 64 | 64 | return $this->api->loadEach($this, Task::class, "{$this}/tasks", $filter); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param array $filter |
| 69 | 69 | * @return Task[] |
| 70 | 70 | */ |
| 71 | - public function getTasks (array $filter = Task::GET_INCOMPLETE) { |
|
| 71 | + public function getTasks(array $filter = Task::GET_INCOMPLETE) { |
|
| 72 | 72 | return iterator_to_array($this->getIterator($filter)); |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | \ No newline at end of file |