Passed
Push — master ( fbd180...23ab98 )
by y
02:18
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   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -54,25 +54,25 @@  discard block
 block discarded – undo
54 54
     /**
55 55
      * @return Cache
56 56
      */
57
-    public static function getCache () {
57
+    public static function getCache() {
58 58
         return static::$cache ?? static::$cache = new Cache();
59 59
     }
60 60
 
61 61
     /**
62 62
      * @return Api
63 63
      */
64
-    public static function getDefault () {
64
+    public static function getDefault() {
65 65
         return self::$default;
66 66
     }
67 67
 
68 68
     /**
69 69
      * @return LoggerInterface
70 70
      */
71
-    public static function getLogger () {
71
+    public static function getLogger() {
72 72
         return static::$logger
73 73
             ?? static::$logger = new class implements LoggerInterface {
74 74
 
75
-                public function log (string $message, string $path, array $data = null): void {
75
+                public function log(string $message, string $path, array $data = null): void {
76 76
                     // stub
77 77
                 }
78 78
 
@@ -82,28 +82,28 @@  discard block
 block discarded – undo
82 82
     /**
83 83
      * @param Cache $cache
84 84
      */
85
-    public static function setCache (Cache $cache) {
85
+    public static function setCache(Cache $cache) {
86 86
         static::$cache = $cache;
87 87
     }
88 88
 
89 89
     /**
90 90
      * @param Api $default
91 91
      */
92
-    public static function setDefault (Api $default) {
92
+    public static function setDefault(Api $default) {
93 93
         self::$default = $default;
94 94
     }
95 95
 
96 96
     /**
97 97
      * @param LoggerInterface $logger
98 98
      */
99
-    public static function setLogger (LoggerInterface $logger) {
99
+    public static function setLogger(LoggerInterface $logger) {
100 100
         static::$logger = $logger;
101 101
     }
102 102
 
103 103
     /**
104 104
      * @param string $token
105 105
      */
106
-    public function __construct (string $token) {
106
+    public function __construct(string $token) {
107 107
         $this->token = $token;
108 108
         if (!static::$default) {
109 109
             static::$default = $this;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      * @return null|array
120 120
      * @internal
121 121
      */
122
-    protected function _exec (string $method, string $path, array $opts = []) {
122
+    protected function _exec(string $method, string $path, array $opts = []) {
123 123
         static::getLogger()->log($method, $path, $opts);
124 124
         /** @var resource $ch */
125 125
         $ch = curl_init();
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      * @return string
169 169
      * @internal
170 170
      */
171
-    protected function _getPath (string $path, array $query): string {
171
+    protected function _getPath(string $path, array $query): string {
172 172
         return $query ? $path . '?' . http_build_query($query) : $path;
173 173
     }
174 174
 
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
      * @return null|array
178 178
      * @internal
179 179
      */
180
-    protected function _jsonDecode (string $json) {
181
-        return json_decode($json, true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR);
180
+    protected function _jsonDecode(string $json) {
181
+        return json_decode($json, true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR);
182 182
     }
183 183
 
184 184
     /**
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
      * @return string
187 187
      * @internal
188 188
      */
189
-    protected function _jsonEncode (array $data): string {
190
-        return json_encode($data, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR);
189
+    protected function _jsonEncode(array $data): string {
190
+        return json_encode($data, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR);
191 191
     }
192 192
 
193 193
     /**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      *
196 196
      * @param string $path
197 197
      */
198
-    public function delete (string $path): void {
198
+    public function delete(string $path): void {
199 199
         $this->_exec('DELETE', $path);
200 200
     }
201 201
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      * @param array $data
210 210
      * @return mixed|Data|AbstractEntity
211 211
      */
212
-    public function factory (string $class, $caller, array $data = []) {
212
+    public function factory(string $class, $caller, array $data = []) {
213 213
         return new $class($caller, $data);
214 214
     }
215 215
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      * @param array $options
222 222
      * @return null|array
223 223
      */
224
-    public function get (string $path, array $query = [], array $options = []) {
224
+    public function get(string $path, array $query = [], array $options = []) {
225 225
         foreach ($options as $name => $value) {
226 226
             $query["opt_{$name}"] = $value;
227 227
         }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
      * @param string $gid
236 236
      * @return null|Attachment
237 237
      */
238
-    public function getAttachment (string $gid) {
238
+    public function getAttachment(string $gid) {
239 239
         return $this->load(Attachment::class, $this, "attachments/{$gid}");
240 240
     }
241 241
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      * @param string $gid
246 246
      * @return null|CustomField
247 247
      */
248
-    public function getCustomField (string $gid) {
248
+    public function getCustomField(string $gid) {
249 249
         return $this->load(CustomField::class, $this, "custom_fields/{$gid}");
250 250
     }
251 251
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
      *
256 256
      * @return Workspace
257 257
      */
258
-    public function getDefaultWorkspace () {
258
+    public function getDefaultWorkspace() {
259 259
         return $this->getMe()->getDefaultWorkspace();
260 260
     }
261 261
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      *
265 265
      * @return User
266 266
      */
267
-    public function getMe () {
267
+    public function getMe() {
268 268
         return $this->getUser('me');
269 269
     }
270 270
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      * @param string $gid
275 275
      * @return null|Portfolio
276 276
      */
277
-    public function getPortfolio (string $gid) {
277
+    public function getPortfolio(string $gid) {
278 278
         return $this->load(Portfolio::class, $this, "portfolios/{$gid}");
279 279
     }
280 280
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      * @param string $gid
285 285
      * @return null|Project
286 286
      */
287
-    public function getProject (string $gid) {
287
+    public function getProject(string $gid) {
288 288
         return $this->load(Project::class, $this, "projects/{$gid}");
289 289
     }
290 290
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
      * @param string $gid
295 295
      * @return null|Section
296 296
      */
297
-    public function getSection (string $gid) {
297
+    public function getSection(string $gid) {
298 298
         return $this->load(Section::class, $this, "sections/{$gid}");
299 299
     }
300 300
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      * @param string $gid
305 305
      * @return null|Story
306 306
      */
307
-    public function getStory (string $gid) {
307
+    public function getStory(string $gid) {
308 308
         return $this->load(Story::class, $this, "stories/{$gid}");
309 309
     }
310 310
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      * @param string $gid
315 315
      * @return null|Tag
316 316
      */
317
-    public function getTag (string $gid) {
317
+    public function getTag(string $gid) {
318 318
         return $this->load(Tag::class, $this, "tags/{$gid}");
319 319
     }
320 320
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
      * @param string $gid
325 325
      * @return null|Task
326 326
      */
327
-    public function getTask (string $gid) {
327
+    public function getTask(string $gid) {
328 328
         return $this->load(Task::class, $this, "tasks/{$gid}");
329 329
     }
330 330
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      * @param string $gid
335 335
      * @return null|TaskList
336 336
      */
337
-    public function getTaskList (string $gid) {
337
+    public function getTaskList(string $gid) {
338 338
         return $this->load(TaskList::class, $this, "user_task_lists/{$gid}");
339 339
     }
340 340
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
      * @param string $gid
345 345
      * @return null|Team
346 346
      */
347
-    public function getTeam (string $gid) {
347
+    public function getTeam(string $gid) {
348 348
         return $this->load(Team::class, $this, "teams/{$gid}");
349 349
     }
350 350
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
      * @param string $gid
355 355
      * @return null|User
356 356
      */
357
-    public function getUser (string $gid) {
357
+    public function getUser(string $gid) {
358 358
         return $this->load(User::class, $this, "users/{$gid}");
359 359
     }
360 360
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
      * @param array $data
367 367
      * @return ProjectEvent|TaskEvent|StoryEvent
368 368
      */
369
-    public function getWebhookEvent (array $data) {
369
+    public function getWebhookEvent(array $data) {
370 370
         static $classes = [
371 371
             Project::TYPE => ProjectEvent::class,
372 372
             Task::TYPE => TaskEvent::class,
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
      * @param string $gid
382 382
      * @return null|Workspace
383 383
      */
384
-    public function getWorkspace (string $gid) {
384
+    public function getWorkspace(string $gid) {
385 385
         return $this->load(Workspace::class, $this, "workspaces/{$gid}");
386 386
     }
387 387
 
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
      * @param string $name
392 392
      * @return null|Workspace
393 393
      */
394
-    public function getWorkspaceByName (string $name) {
394
+    public function getWorkspaceByName(string $name) {
395 395
         foreach ($this->getWorkspaces() as $workspace) {
396 396
             if ($workspace->getName() === $name) {
397 397
                 return $workspace;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      *
406 406
      * @return Workspace[]
407 407
      */
408
-    public function getWorkspaces () {
408
+    public function getWorkspaces() {
409 409
         return $this->getMe()->getWorkspaces();
410 410
     }
411 411
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
      * @param array $query
421 421
      * @return null|mixed|AbstractEntity
422 422
      */
423
-    public function load (string $class, $caller, string $path, array $query = []) {
423
+    public function load(string $class, $caller, string $path, array $query = []) {
424 424
         $key = $this->_getPath($path, $query);
425 425
         return $this->getCache()->get($key, $caller, function($caller) use ($class, $path, $query) {
426 426
             $data = $this->get($path, $query, ['expand' => 'this']);
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
      * @param int $pages
439 439
      * @return array|AbstractEntity[]
440 440
      */
441
-    public function loadAll (string $class, $caller, string $path, array $query = [], int $pages = 0) {
441
+    public function loadAll(string $class, $caller, string $path, array $query = [], int $pages = 0) {
442 442
         return iterator_to_array($this->loadEach(...func_get_args()));
443 443
     }
444 444
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
      * @param int $pages If positive, stops after this many pages have been fetched.
455 455
      * @return Generator|AbstractEntity[]
456 456
      */
457
-    public function loadEach (string $class, $caller, string $path, array $query = [], int $pages = 0) {
457
+    public function loadEach(string $class, $caller, string $path, array $query = [], int $pages = 0) {
458 458
         $query['opt_expand'] = 'this';
459 459
         $query += ['limit' => 100];
460 460
         $path = $this->_getPath($path, $query);
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
      * @param array $options
479 479
      * @return null|array
480 480
      */
481
-    public function post (string $path, array $data = [], array $options = []) {
481
+    public function post(string $path, array $data = [], array $options = []) {
482 482
         $response = $this->_exec('POST', $path, [
483 483
             CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
484 484
             CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data])
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
      * @param array $options
495 495
      * @return null|array
496 496
      */
497
-    public function put (string $path, array $data = [], array $options = []) {
497
+    public function put(string $path, array $data = [], array $options = []) {
498 498
         $response = $this->_exec('PUT', $path, [
499 499
             CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
500 500
             CURLOPT_POSTFIELDS => $this->_jsonEncode(['options' => $options, 'data' => $data])
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
      * @param null|string $token
514 514
      * @return ProjectEvent[]|TaskEvent[]|StoryEvent[]
515 515
      */
516
-    public function sync ($entity, ?string &$token) {
516
+    public function sync($entity, ?string &$token) {
517 517
         try {
518 518
             $response = $this->_exec('GET', $this->_getPath('events', [
519 519
                 'resource' => $entity->getGid(),
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
      * @param string $file
549 549
      * @return null|array
550 550
      */
551
-    public function upload (string $path, string $file) {
551
+    public function upload(string $path, string $file) {
552 552
         $response = $this->_exec('POST', $path, [
553 553
             CURLOPT_POSTFIELDS => ['file' => new CURLFile(realpath($file))] // multipart/form-data
554 554
         ]);
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/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/Api/Cache.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * @param AbstractEntity $entity
35 35
      * @return bool Success
36 36
      */
37
-    public function add (AbstractEntity $entity): bool {
37
+    public function add(AbstractEntity $entity): bool {
38 38
         if ($gid = $entity->getGid() and !$entity->isDiff()) {
39 39
             $this->entities[$gid] = $entity;
40 40
             $this->addKeys($gid, $entity->getCacheKeys());
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      * @param string $gid
50 50
      * @param string[] $keys
51 51
      */
52
-    protected function addKeys (string $gid, array $keys): void {
52
+    protected function addKeys(string $gid, array $keys): void {
53 53
         $this->gids += array_fill_keys($keys, $gid);
54 54
     }
55 55
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      * @param Closure $factory `fn( Api|Data $caller ): null|AbstractEntity`
65 65
      * @return null|mixed|AbstractEntity
66 66
      */
67
-    public function get (string $key, $caller, Closure $factory) {
67
+    public function get(string $key, $caller, Closure $factory) {
68 68
         // POOL HIT
69 69
         if ($gid = $this->gids[$key] ?? null) {
70 70
             return $this->entities[$gid];
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      *
93 93
      * @param AbstractEntity $entity
94 94
      */
95
-    public function remove (AbstractEntity $entity): void {
95
+    public function remove(AbstractEntity $entity): void {
96 96
         $gid = $entity->getGid();
97 97
         unset($this->entities[$gid]);
98 98
         foreach ($entity->getCacheKeys() as $key) {
Please login to merge, or discard this patch.
src/Api/LoggerInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,5 +12,5 @@
 block discarded – undo
12 12
      * @param string $path
13 13
      * @param null|array $data
14 14
      */
15
-    public function log (string $message, string $path, array $data = null): void;
15
+    public function log(string $message, string $path, array $data = null): void;
16 16
 }
17 17
\ No newline at end of file
Please login to merge, or discard this patch.