Passed
Push — master ( 528684...097ab9 )
by y
13:21 queued 01:43
created
src/Color.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     /**
36 36
      * @return string
37 37
      */
38
-    public static function random () {
38
+    public static function random() {
39 39
         try {
40 40
             $colors = (new ReflectionClass(self::class))->getConstants();
41 41
             return $colors[array_rand($colors)];
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,8 +39,7 @@
 block discarded – undo
39 39
         try {
40 40
             $colors = (new ReflectionClass(self::class))->getConstants();
41 41
             return $colors[array_rand($colors)];
42
-        }
43
-        catch (Exception $exception) {
42
+        } catch (Exception $exception) {
44 43
             return 'none'; // unreachable
45 44
         }
46 45
     }
Please login to merge, or discard this patch.
src/Webhook/AbstractWebhook.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
     }
31 31
     use DeleteTrait;
32 32
 
33
-    final public function __toString (): string {
33
+    final public function __toString(): string {
34 34
         return "webhooks/{$this->getGid()}";
35 35
     }
36 36
 
37
-    final protected function _getDir (): string {
37
+    final protected function _getDir(): string {
38 38
         return 'webhooks';
39 39
     }
40 40
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @param string $target
44 44
      * @return $this
45 45
      */
46
-    public function create ($resource, string $target) {
46
+    public function create($resource, string $target) {
47 47
         $this->_set('resource', $resource);
48 48
         $this->_set('target', $target);
49 49
         return $this->_create();
Please login to merge, or discard this patch.
src/Api.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -460,8 +460,7 @@
 block discarded – undo
460 460
                 'sync' => $token,
461 461
                 'opt_expand' => 'this'
462 462
             ]));
463
-        }
464
-        catch (Error $error) {
463
+        } catch (Error $error) {
465 464
             if ($error->getCode() !== 412) {
466 465
                 throw $error;
467 466
             }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 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 (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
 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(Attachment::class, $this, "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(CustomField::class, $this, "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(Portfolio::class, $this, "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(Project::class, $this, "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(Section::class, $this, "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(Story::class, $this, "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(Tag::class, $this, "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(Task::class, $this, "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(TaskList::class, $this, "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(Team::class, $this, "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(User::class, $this, "users/{$gid}");
358 358
     }
359 359
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         ]);
Please login to merge, or discard this patch.
src/Error.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Api/Laravel/Facade/Asana.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -49,21 +49,21 @@
 block discarded – undo
49 49
     /**
50 50
      * @return Api
51 51
      */
52
-    final public static function getApi () {
52
+    final public static function getApi() {
53 53
         return static::getFacadeRoot();
54 54
     }
55 55
 
56 56
     /**
57 57
      * @return string
58 58
      */
59
-    public static function getFacadeAccessor () {
59
+    public static function getFacadeAccessor() {
60 60
         return AsanaServiceProvider::NAME;
61 61
     }
62 62
 
63 63
     /**
64 64
      * @return Api
65 65
      */
66
-    public static function getFacadeRoot () {
66
+    public static function getFacadeRoot() {
67 67
         return parent::getFacadeRoot();
68 68
     }
69 69
 }
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
src/Tag.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@
 block discarded – undo
31 31
         'workspace' => Workspace::class
32 32
     ];
33 33
 
34
-    final public function __toString (): string {
34
+    final public function __toString(): string {
35 35
         return "tags/{$this->getGid()}";
36 36
     }
37 37
 
38
-    final protected function _getDir (): string {
38
+    final protected function _getDir(): string {
39 39
         return 'tags';
40 40
     }
41 41
 
42 42
     /**
43 43
      * @return Task[]
44 44
      */
45
-    public function getTasks () {
45
+    public function getTasks() {
46 46
         return $this->loadAll(Task::class, "{$this}/tasks");
47 47
     }
48 48
 }
49 49
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/Laravel/AsanaServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@
 block discarded – undo
14 14
 
15 15
     const NAME = 'asana';
16 16
 
17
-    public function boot () {
17
+    public function boot() {
18 18
         $this->mergeConfigFrom(App::configPath('asana.php'), self::NAME);
19 19
     }
20 20
 
21
-    public function register () {
21
+    public function register() {
22 22
         // cli: announce config file
23 23
         if (App::runningInConsole() and !Str::contains($this->app->version(), 'Lumen')) {
24 24
             $this->publishes([__DIR__ . '/config/asana.php' => App::configPath('asana.php')], 'config');
Please login to merge, or discard this patch.
src/Task/Attachment.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         'parent' => Task::class
33 33
     ];
34 34
 
35
-    final public function __toString (): string {
35
+    final public function __toString(): string {
36 36
         return "attachments/{$this->getGid()}";
37 37
     }
38 38
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param string $file
45 45
      * @return $this
46 46
      */
47
-    public function upload (string $file) {
47
+    public function upload(string $file) {
48 48
         // api returns compact version. reload.
49 49
         /** @var array $remote */
50 50
         $remote = $this->api->upload("{$this->getParent()}/attachments", $file);
Please login to merge, or discard this patch.
src/Portfolio.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
         'workspace' => Workspace::class
40 40
     ];
41 41
 
42
-    final public function __toString (): string {
42
+    final public function __toString(): string {
43 43
         return "portfolios/{$this->getGid()}";
44 44
     }
45 45
 
46
-    final protected function _getDir (): string {
46
+    final protected function _getDir(): string {
47 47
         return 'portfolios';
48 48
     }
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @param Project $item
53 53
      * @return $this
54 54
      */
55
-    public function addItem (Project $item) {
55
+    public function addItem(Project $item) {
56 56
         $this->api->post("{$this}/addItem", ['item' => $item->getGid()]);
57 57
         return $this;
58 58
     }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param User $user
62 62
      * @return $this
63 63
      */
64
-    public function addMember (User $user) {
64
+    public function addMember(User $user) {
65 65
         return $this->addMembers([$user]);
66 66
     }
67 67
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @param User[] $users
70 70
      * @return $this
71 71
      */
72
-    public function addMembers (array $users) {
72
+    public function addMembers(array $users) {
73 73
         return $this->_addWithPost("{$this}/addMembers", [
74 74
             'members' => array_column($users, 'gid')
75 75
         ], 'members', $users);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      * @depends after-create
80 80
      * @return Project[]
81 81
      */
82
-    public function getItems () {
82
+    public function getItems() {
83 83
         return $this->loadAll(Project::class, "{$this}/items");
84 84
     }
85 85
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      * @param Project $item
89 89
      * @return $this
90 90
      */
91
-    public function removeItem (Project $item) {
91
+    public function removeItem(Project $item) {
92 92
         $this->api->post("{$this}/removeItem", ['item' => $item->getGid()]);
93 93
         return $this;
94 94
     }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      * @param User $user
98 98
      * @return $this
99 99
      */
100
-    public function removeMember (User $user) {
100
+    public function removeMember(User $user) {
101 101
         return $this->removeMembers([$user]);
102 102
     }
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      * @param User[] $users
106 106
      * @return $this
107 107
      */
108
-    public function removeMembers (array $users) {
108
+    public function removeMembers(array $users) {
109 109
         return $this->_removeWithPost("{$this}/removeMembers", [
110 110
             'members' => array_column($users, 'gid')
111 111
         ], 'members', $users);
Please login to merge, or discard this patch.