Passed
Push — master ( c517f3...89c195 )
by y
12:44
created
src/Event.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,35 +59,35 @@
 block discarded – undo
59 59
     /**
60 60
      * @return bool
61 61
      */
62
-    final public function wasAddition (): bool {
62
+    final public function wasAddition(): bool {
63 63
         return $this->getAction() === self::ACTION_ADDED;
64 64
     }
65 65
 
66 66
     /**
67 67
      * @return bool
68 68
      */
69
-    final public function wasChange (): bool {
69
+    final public function wasChange(): bool {
70 70
         return $this->getAction() === self::ACTION_CHANGED;
71 71
     }
72 72
 
73 73
     /**
74 74
      * @return bool
75 75
      */
76
-    final public function wasDeletion (): bool {
76
+    final public function wasDeletion(): bool {
77 77
         return $this->getAction() === self::ACTION_DELETED;
78 78
     }
79 79
 
80 80
     /**
81 81
      * @return bool
82 82
      */
83
-    final public function wasRemoval (): bool {
83
+    final public function wasRemoval(): bool {
84 84
         return $this->getAction() === self::ACTION_REMOVED;
85 85
     }
86 86
 
87 87
     /**
88 88
      * @return bool
89 89
      */
90
-    final public function wasUndeletion (): bool {
90
+    final public function wasUndeletion(): bool {
91 91
         return $this->getAction() === self::ACTION_UNDELETED;
92 92
     }
93 93
 
Please login to merge, or discard this patch.
src/User.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         'workspaces' => [Workspace::class]
29 29
     ];
30 30
 
31
-    final public function __toString (): string {
31
+    final public function __toString(): string {
32 32
         return "users/{$this->getGid()}";
33 33
     }
34 34
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * @param Workspace $workspace
37 37
      * @return $this
38 38
      */
39
-    public function addToWorkspace (Workspace $workspace) {
39
+    public function addToWorkspace(Workspace $workspace) {
40 40
         return $this->_addWithPost("{$workspace}/addUser", [
41 41
             'user' => $this->getGid()
42 42
         ], 'workspaces', [$workspace]);
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     /**
46 46
      * @return string[]
47 47
      */
48
-    public function getCacheKeys () {
48
+    public function getCacheKeys() {
49 49
         $keys = parent::getCacheKeys();
50 50
 
51 51
         // only include email as a key if it's loaded
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      *
63 63
      * @return Workspace
64 64
      */
65
-    public function getDefaultWorkspace () {
65
+    public function getDefaultWorkspace() {
66 66
         return $this->getWorkspaces()[0];
67 67
     }
68 68
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param null|Workspace $workspace Falls back to the default workspace.
71 71
      * @return Portfolio[]
72 72
      */
73
-    public function getFavoritePortfolios (Workspace $workspace = null) {
73
+    public function getFavoritePortfolios(Workspace $workspace = null) {
74 74
         return $this->getFavorites(Portfolio::class, Portfolio::TYPE, $workspace);
75 75
     }
76 76
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @param null|Workspace $workspace Falls back to the default workspace.
79 79
      * @return Project[]
80 80
      */
81
-    public function getFavoriteProjects (Workspace $workspace = null) {
81
+    public function getFavoriteProjects(Workspace $workspace = null) {
82 82
         return $this->getFavorites(Project::class, Project::TYPE, $workspace);
83 83
     }
84 84
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * @param null|Workspace $workspace Falls back to the default workspace.
87 87
      * @return Tag[]
88 88
      */
89
-    public function getFavoriteTags (Workspace $workspace = null) {
89
+    public function getFavoriteTags(Workspace $workspace = null) {
90 90
         return $this->getFavorites(Tag::class, Tag::TYPE, $workspace);
91 91
     }
92 92
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      * @param null|Workspace $workspace Falls back to the default workspace.
95 95
      * @return Team[]
96 96
      */
97
-    public function getFavoriteTeams (Workspace $workspace = null) {
97
+    public function getFavoriteTeams(Workspace $workspace = null) {
98 98
         return $this->getFavorites(Team::class, Team::TYPE, $workspace);
99 99
     }
100 100
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @param null|Workspace $workspace Falls back to the default workspace.
103 103
      * @return User[]
104 104
      */
105
-    public function getFavoriteUsers (Workspace $workspace = null) {
105
+    public function getFavoriteUsers(Workspace $workspace = null) {
106 106
         return $this->getFavorites(self::class, self::TYPE, $workspace);
107 107
     }
108 108
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      * @param null|Workspace $workspace Falls back to the default workspace.
113 113
      * @return array
114 114
      */
115
-    protected function getFavorites (string $class, string $resourceType, Workspace $workspace = null) {
115
+    protected function getFavorites(string $class, string $resourceType, Workspace $workspace = null) {
116 116
         return $this->api->loadAll($this, $class, "{$this}/favorites", [
117 117
             'resource_type' => $resourceType,
118 118
             'workspace' => ($workspace ?? $this->api->getDefaultWorkspace())->getGid()
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      * @param null|Workspace $workspace
124 124
      * @return Portfolio[]
125 125
      */
126
-    public function getPortfolios (Workspace $workspace = null) {
126
+    public function getPortfolios(Workspace $workspace = null) {
127 127
         return $this->api->loadAll($this, Portfolio::class, "portfolios", [
128 128
             'workspace' => ($workspace ?? $this->api->getDefaultWorkspace())->getGid(),
129 129
             'owner' => $this->getGid()
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      * @param null|Workspace $workspace Falls back to the default workspace.
135 135
      * @return TaskList
136 136
      */
137
-    public function getTaskList (Workspace $workspace = null) {
137
+    public function getTaskList(Workspace $workspace = null) {
138 138
         return $this->api->load($this, TaskList::class, "{$this}/user_task_list", [
139 139
             'workspace' => ($workspace ?? $this->api->getDefaultWorkspace())->getGid()
140 140
         ]);
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      * @param string[] $filter `workspace` falls back to the default.
147 147
      * @return Task[]
148 148
      */
149
-    public function getTasks (array $filter = []) {
149
+    public function getTasks(array $filter = []) {
150 150
         $filter['assignee'] = $this->getGid();
151 151
         $filter += ['workspace' => $this->api->getDefaultWorkspace()->getGid()];
152 152
         return $this->api->loadAll($this, Task::class, 'tasks', $filter);
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
      * @param null|Workspace $organization Falls back to the default workspace.
161 161
      * @return Team[]
162 162
      */
163
-    public function getTeams (Workspace $organization = null) {
163
+    public function getTeams(Workspace $organization = null) {
164 164
         return $this->api->loadAll($this, Team::class, "{$this}/teams", [
165 165
             'organization' => ($organization ?? $this->getDefaultWorkspace())->getGid()
166 166
         ]);
167 167
     }
168 168
 
169
-    public function getUrl (): string {
169
+    public function getUrl(): string {
170 170
         return "https://app.asana.com/0/{$this->getGid()}/list";
171 171
     }
172 172
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      * @param Workspace $workspace
175 175
      * @return $this
176 176
      */
177
-    public function removeFromWorkspace (Workspace $workspace) {
177
+    public function removeFromWorkspace(Workspace $workspace) {
178 178
         return $this->_removeWithPost("{$workspace}/removeUser", [
179 179
             'user' => $this->getGid()
180 180
         ], 'workspaces', [$workspace]);
Please login to merge, or discard this patch.
src/Api.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -53,25 +53,25 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
208 208
      * @param array $data
209 209
      * @return mixed|Data|AbstractEntity
210 210
      */
211
-    public function factory ($caller, string $class, array $data = []) {
211
+    public function factory($caller, string $class, array $data = []) {
212 212
         return new $class($caller, $data);
213 213
     }
214 214
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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($this, Attachment::class, "attachments/{$gid}");
239 239
     }
240 240
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
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($this, CustomField::class, "custom_fields/{$gid}");
249 249
     }
250 250
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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($this, Portfolio::class, "portfolios/{$gid}");
278 278
     }
279 279
 
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
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($this, Project::class, "projects/{$gid}");
288 288
     }
289 289
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
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($this, Section::class, "sections/{$gid}");
298 298
     }
299 299
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
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($this, Story::class, "stories/{$gid}");
308 308
     }
309 309
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
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($this, Tag::class, "tags/{$gid}");
318 318
     }
319 319
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
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($this, Task::class, "tasks/{$gid}");
328 328
     }
329 329
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
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($this, TaskList::class, "user_task_lists/{$gid}");
338 338
     }
339 339
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
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($this, Team::class, "teams/{$gid}");
348 348
     }
349 349
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
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($this, User::class, "users/{$gid}");
358 358
     }
359 359
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
      * @param string $gid
362 362
      * @return ProjectWebhook|TaskWebhook
363 363
      */
364
-    public function getWebhook (string $gid) {
364
+    public function getWebhook(string $gid) {
365 365
         return $this->getCache()->get($gid, $this, function() use ($gid) {
366 366
             static $classes = [
367 367
                 Project::TYPE => ProjectWebhook::class,
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      * @param array $data
383 383
      * @return Event
384 384
      */
385
-    public function getWebhookEvent (array $data) {
385
+    public function getWebhookEvent(array $data) {
386 386
         return $this->factory($this, Event::class, $data);
387 387
     }
388 388
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
      * @param string $gid
393 393
      * @return null|Workspace
394 394
      */
395
-    public function getWorkspace (string $gid) {
395
+    public function getWorkspace(string $gid) {
396 396
         return $this->load($this, Workspace::class, "workspaces/{$gid}");
397 397
     }
398 398
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
      * @param string $name
403 403
      * @return null|Workspace
404 404
      */
405
-    public function getWorkspaceByName (string $name) {
405
+    public function getWorkspaceByName(string $name) {
406 406
         foreach ($this->getWorkspaces() as $workspace) {
407 407
             if ($workspace->getName() === $name) {
408 408
                 return $workspace;
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
      *
417 417
      * @return Workspace[]
418 418
      */
419
-    public function getWorkspaces () {
419
+    public function getWorkspaces() {
420 420
         return $this->getMe()->getWorkspaces();
421 421
     }
422 422
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
      * @param array $query
432 432
      * @return null|mixed|AbstractEntity
433 433
      */
434
-    public function load ($caller, string $class, string $path, array $query = []) {
434
+    public function load($caller, string $class, string $path, array $query = []) {
435 435
         $key = $this->_getPath($path, $query);
436 436
         return $this->getCache()->get($key, $caller, function($caller) use ($class, $path, $query) {
437 437
             $data = $this->get($path, $query, ['expand' => 'this']);
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
      * @param int $pages
450 450
      * @return array|AbstractEntity[]
451 451
      */
452
-    public function loadAll ($caller, string $class, string $path, array $query = [], int $pages = 0) {
452
+    public function loadAll($caller, string $class, string $path, array $query = [], int $pages = 0) {
453 453
         return iterator_to_array($this->loadEach(...func_get_args()));
454 454
     }
455 455
 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
      * @param int $pages If positive, stops after this many pages have been fetched.
466 466
      * @return Generator|AbstractEntity[]
467 467
      */
468
-    public function loadEach ($caller, string $class, string $path, array $query = [], int $pages = 0) {
468
+    public function loadEach($caller, string $class, string $path, array $query = [], int $pages = 0) {
469 469
         $hardLimit = isset($query['limit']);
470 470
         $query['opt_expand'] = 'this';
471 471
         $query += ['limit' => 100];
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
      * @param array $options
491 491
      * @return null|array
492 492
      */
493
-    public function post (string $path, array $data = [], array $options = []) {
493
+    public function post(string $path, array $data = [], array $options = []) {
494 494
         $response = $this->_exec('POST', $path, [
495 495
             CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
496 496
             CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data])
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
      * @param array $options
507 507
      * @return null|array
508 508
      */
509
-    public function put (string $path, array $data = [], array $options = []) {
509
+    public function put(string $path, array $data = [], array $options = []) {
510 510
         $response = $this->_exec('PUT', $path, [
511 511
             CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
512 512
             CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data])
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
      * @param null|string $token
526 526
      * @return Event[]
527 527
      */
528
-    public function sync ($entity, ?string &$token) {
528
+    public function sync($entity, ?string &$token) {
529 529
         try {
530 530
             $response = $this->_exec('GET', $this->_getPath('events', [
531 531
                 'resource' => $entity->getGid(),
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
      * @param string $to
556 556
      * @return null|array
557 557
      */
558
-    public function upload (string $file, string $to) {
558
+    public function upload(string $file, string $to) {
559 559
         $response = $this->_exec('POST', $to, [
560 560
             CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data
561 561
         ]);
Please login to merge, or discard this patch.