Passed
Push — master ( dba318...93b4f6 )
by y
01:38
created
src/Job.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
     const STATUS_SUCCESS = 'succeeded'; // api docs say "completed" but that's wrong.
29 29
     const STATUS_FAIL = 'failed';
30 30
 
31
-    final public function __toString (): string {
31
+    final public function __toString(): string {
32 32
         return "jobs/{$this->getGid()}";
33 33
     }
34 34
 
35
-    protected function _getMap (): array {
35
+    protected function _getMap(): array {
36 36
         return [
37 37
             'new_project' => Project::class,
38 38
             'new_task' => Task::class
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      *
45 45
      * @return bool
46 46
      */
47
-    public function isActive (): bool {
47
+    public function isActive(): bool {
48 48
         return $this->getStatus() === self::STATUS_ACTIVE;
49 49
     }
50 50
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      *
54 54
      * @return bool
55 55
      */
56
-    public function isDone (): bool {
56
+    public function isDone(): bool {
57 57
         return $this->isSuccessful() or $this->isFailed();
58 58
     }
59 59
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      *
63 63
      * @return bool
64 64
      */
65
-    public function isFailed (): bool {
65
+    public function isFailed(): bool {
66 66
         return $this->getStatus() === self::STATUS_FAIL;
67 67
     }
68 68
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      *
72 72
      * @return bool
73 73
      */
74
-    public function isQueued (): bool {
74
+    public function isQueued(): bool {
75 75
         return $this->getStatus() === self::STATUS_QUEUED;
76 76
     }
77 77
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @return bool
82 82
      */
83
-    public function isSuccessful (): bool {
83
+    public function isSuccessful(): bool {
84 84
         return $this->getStatus() === self::STATUS_SUCCESS;
85 85
     }
86 86
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      *
90 90
      * @return $this
91 91
      */
92
-    public function wait () {
92
+    public function wait() {
93 93
         while (!$this->isDone()) {
94 94
             sleep(3);
95 95
             $this->reload();
Please login to merge, or discard this patch.
src/Base/AbstractEntity/WorkspaceTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
      * @param Workspace $workspace
18 18
      * @return $this
19 19
      */
20
-    public function setWorkspace (Workspace $workspace) {
20
+    public function setWorkspace(Workspace $workspace) {
21 21
         assert(!$this->hasGid());
22 22
         return $this->_set('workspace', $workspace);
23 23
     }
Please login to merge, or discard this patch.
src/Base/AbstractEntity.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      *
17 17
      * @return string
18 18
      */
19
-    abstract public function __toString (): string;
19
+    abstract public function __toString(): string;
20 20
 
21 21
     /**
22 22
      * Resolves entities to GIDs.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * @param AbstractEntity[] $entities
25 25
      * @return string[]
26 26
      */
27
-    protected static function _getGids (array $entities) {
27
+    protected static function _getGids(array $entities) {
28 28
         return array_map(function(AbstractEntity $entity) {
29 29
             return $entity->getGid();
30 30
         }, $entities);
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * @param string $key
37 37
      * @return mixed
38 38
      */
39
-    protected function _get (string $key) {
39
+    protected function _get(string $key) {
40 40
         if (!array_key_exists($key, $this->data) and isset($this->data['gid'])) { // can't use hasGid(), inf. loop
41 41
             $this->reload($key);
42 42
         }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      * @param bool $force
52 52
      * @return $this
53 53
      */
54
-    protected function _merge (string $key, array $entities, $force = false) {
54
+    protected function _merge(string $key, array $entities, $force = false) {
55 55
         if ($force or isset($this->data[$key])) {
56 56
             foreach ($entities as $entity) {
57 57
                 $this->data[$key][] = $entity;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param AbstractEntity[] $entities
75 75
      * @return $this
76 76
      */
77
-    protected function _remove (string $key, array $entities) {
77
+    protected function _remove(string $key, array $entities) {
78 78
         if (isset($this->data[$key])) {
79 79
             $this->data[$key] = array_values(array_diff($this->data[$key], $entities));
80 80
             $this->api->getCache()->add($this);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      * @param AbstractEntity $entity
89 89
      * @return $this
90 90
      */
91
-    public function merge (AbstractEntity $entity) {
91
+    public function merge(AbstractEntity $entity) {
92 92
         assert($entity->api); // hydrated
93 93
         foreach ($entity->data as $key => $value) {
94 94
             if (!array_key_exists($key, $this->data) and !isset($entity->diff[$key])) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @param string $key
105 105
      * @return $this
106 106
      */
107
-    public function reload (string $key = null) {
107
+    public function reload(string $key = null) {
108 108
         if (isset($key)) {
109 109
             $value = $this->api->get($this, [], ['fields' => $key])[$key];
110 110
             $map = $this->_getMap();
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,8 +59,7 @@  discard block
 block discarded – undo
59 59
             $this->data[$key] = array_values(array_unique($this->data[$key]));
60 60
             if ($force) {
61 61
                 $this->diff[$key] = true;
62
-            }
63
-            else {
62
+            } else {
64 63
                 $this->api->getCache()->add($this);
65 64
             }
66 65
         }
@@ -110,8 +109,7 @@  discard block
 block discarded – undo
110 109
             $map = $this->_getMap();
111 110
             $this->data[$key] = isset($map[$key]) ? $this->_getMapped($map[$key], $value) : $value;
112 111
             unset($this->diff[$key]);
113
-        }
114
-        else {
112
+        } else {
115 113
             $this->_setData($this->api->get($this, [], ['expand' => 'this']));
116 114
         }
117 115
         $this->api->getCache()->add($this);
Please login to merge, or discard this patch.
src/Base/Data.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -291,11 +291,9 @@
 block discarded – undo
291 291
         $dehydrate = function($each) use (&$dehydrate) {
292 292
             if ($each instanceof AbstractEntity and $each->hasGid()) {
293 293
                 return $each->getGid();
294
-            }
295
-            elseif ($each instanceof self) {
294
+            } elseif ($each instanceof self) {
296 295
                 return $each->toArray();
297
-            }
298
-            elseif (is_array($each)) {
296
+            } elseif (is_array($each)) {
299 297
                 return array_map($dehydrate, $each);
300 298
             }
301 299
             return $each;
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      * @param Api|Data $caller
31 31
      * @param array $data
32 32
      */
33
-    public function __construct ($caller, array $data = []) {
33
+    public function __construct($caller, array $data = []) {
34 34
         $this->api = $caller instanceof self ? $caller->api : $caller;
35 35
         $this->_setData($data);
36 36
     }
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      * @param array $args
47 47
      * @return mixed
48 48
      */
49
-    public function __call (string $method, array $args) {
49
+    public function __call(string $method, array $args) {
50 50
         static $cache = [];
51
-        if (!$call =& $cache[$method]) {
51
+        if (!$call = & $cache[$method]) {
52 52
             preg_match('/^(get|has|is|set)(.+)$/', $method, $call);
53 53
             $call[1] = '_' . $call[1];
54 54
             $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) {
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         return $this->{$call[1]}($call[2], ...$args);
59 59
     }
60 60
 
61
-    public function __debugInfo (): array {
61
+    public function __debugInfo(): array {
62 62
         return $this->data;
63 63
     }
64 64
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param string $key
71 71
      * @return mixed
72 72
      */
73
-    protected function _get (string $key) {
73
+    protected function _get(string $key) {
74 74
         return $this->data[$key] ?? null;
75 75
     }
76 76
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @return array
84 84
      */
85
-    protected function _getMap (): array {
85
+    protected function _getMap(): array {
86 86
         return [];
87 87
     }
88 88
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @param null|self|array $value
92 92
      * @return null|Data|Data[]
93 93
      */
94
-    protected function _getMapped ($class, $value) {
94
+    protected function _getMapped($class, $value) {
95 95
         // use empty|Data|Data[] as-is
96 96
         if (!$value or $value instanceof self or current($value) instanceof self) {
97 97
             return $value;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      *
125 125
      * @return array
126 126
      */
127
-    protected function _getPatch (): array {
127
+    protected function _getPatch(): array {
128 128
         $convert = function($each) use (&$convert) {
129 129
             // convert existing entities to gids
130 130
             if ($each instanceof AbstractEntity and $each->hasGid()) {
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      * @param string $key
155 155
      * @return bool
156 156
      */
157
-    protected function _has (string $key): bool {
157
+    protected function _has(string $key): bool {
158 158
         $value = $this->_get($key);
159 159
         if (isset($value)) {
160 160
             if (is_countable($value)) {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      * @param string $key
178 178
      * @return bool
179 179
      */
180
-    protected function _is (string $key): bool {
180
+    protected function _is(string $key): bool {
181 181
         return !empty($this->_get($key));
182 182
     }
183 183
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      * @param mixed $value
191 191
      * @return $this
192 192
      */
193
-    protected function _set (string $key, $value) {
193
+    protected function _set(string $key, $value) {
194 194
         $this->data[$key] = $value;
195 195
         $this->diff[$key] = true;
196 196
         return $this;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      * @param array $data
203 203
      * @return $this
204 204
      */
205
-    protected function _setData (array $data) {
205
+    protected function _setData(array $data) {
206 206
         $map = $this->_getMap();
207 207
         /** @var null|self|array $value */
208 208
         foreach (array_intersect_key($data, $map) as $key => $value) {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      * @param array $data
221 221
      * @return mixed
222 222
      */
223
-    final protected function factory (string $class, array $data = []) {
223
+    final protected function factory(string $class, array $data = []) {
224 224
         return $this->api->factory($class, $this, $data);
225 225
     }
226 226
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
      *
230 230
      * @return bool
231 231
      */
232
-    final public function isDiff (): bool {
232
+    final public function isDiff(): bool {
233 233
         return (bool)$this->diff;
234 234
     }
235 235
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      * @see toArray()
238 238
      * @return array
239 239
      */
240
-    public function jsonSerialize (): array {
240
+    public function jsonSerialize(): array {
241 241
         return $this->toArray();
242 242
     }
243 243
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      * @param array $query
252 252
      * @return null|mixed|AbstractEntity
253 253
      */
254
-    final protected function load (string $class, string $path, array $query = []) {
254
+    final protected function load(string $class, string $path, array $query = []) {
255 255
         return $this->api->load($class, $this, $path, $query);
256 256
     }
257 257
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      * @param int $pages
267 267
      * @return array|AbstractEntity[]
268 268
      */
269
-    final protected function loadAll (string $class, string $path, array $query = [], int $pages = 0) {
269
+    final protected function loadAll(string $class, string $path, array $query = [], int $pages = 0) {
270 270
         return $this->api->loadAll($class, $this, $path, $query, $pages);
271 271
     }
272 272
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      *
278 278
      * @return string
279 279
      */
280
-    public function serialize (): string {
280
+    public function serialize(): string {
281 281
         return serialize($this->toArray());
282 282
     }
283 283
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
      *
287 287
      * @return array
288 288
      */
289
-    public function toArray (): array {
289
+    public function toArray(): array {
290 290
         if (!$this->api) {
291 291
             return $this->data;
292 292
         }
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      *
313 313
      * @param $serialized
314 314
      */
315
-    public function unserialize ($serialized): void {
315
+    public function unserialize($serialized): void {
316 316
         $this->data = unserialize($serialized);
317 317
     }
318 318
 }
319 319
\ No newline at end of file
Please login to merge, or discard this patch.
src/Portfolio.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,8 +73,7 @@
 block discarded – undo
73 73
         if ($this->hasGid()) {
74 74
             $this->api->post("{$this}/addMembers", ['members' => static::_getGids($users)]);
75 75
             $this->_merge('members', $users);
76
-        }
77
-        else {
76
+        } else {
78 77
             $this->_merge('members', $users, true);
79 78
         }
80 79
         return $this;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,15 +30,15 @@  discard block
 block discarded – undo
30 30
 
31 31
     const TYPE = 'portfolio';
32 32
 
33
-    final public function __toString (): string {
33
+    final public function __toString(): string {
34 34
         return "portfolios/{$this->getGid()}";
35 35
     }
36 36
 
37
-    final protected function _getDir (): string {
37
+    final protected function _getDir(): string {
38 38
         return 'portfolios';
39 39
     }
40 40
 
41
-    protected function _getMap (): array {
41
+    protected function _getMap(): array {
42 42
         return [
43 43
             'created_by' => User::class,
44 44
             'owner' => User::class,
@@ -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
         if ($this->hasGid()) {
74 74
             $this->api->post("{$this}/addMembers", ['members' => static::_getGids($users)]);
75 75
             $this->_merge('members', $users);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @depends after-create
85 85
      * @return Project[]
86 86
      */
87
-    public function getItems () {
87
+    public function getItems() {
88 88
         return $this->loadAll(Project::class, "{$this}/items");
89 89
     }
90 90
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      * @param Project $item
94 94
      * @return $this
95 95
      */
96
-    public function removeItem (Project $item) {
96
+    public function removeItem(Project $item) {
97 97
         $this->api->post("{$this}/removeItem", ['item' => $item->getGid()]);
98 98
         return $this;
99 99
     }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @param User $user
103 103
      * @return $this
104 104
      */
105
-    public function removeMember (User $user) {
105
+    public function removeMember(User $user) {
106 106
         return $this->removeMembers([$user]);
107 107
     }
108 108
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      * @param User[] $users
111 111
      * @return $this
112 112
      */
113
-    public function removeMembers (array $users) {
113
+    public function removeMembers(array $users) {
114 114
         if ($this->hasGid()) {
115 115
             $this->api->post("{$this}/removeMembers", ['members' => static::_getGids($users)]);
116 116
         }
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
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      *
33 33
      * @param AbstractEntity $entity
34 34
      */
35
-    public function add (AbstractEntity $entity): void {
35
+    public function add(AbstractEntity $entity): void {
36 36
         if ($gid = $entity->getGid() and !$entity->isDiff()) {
37 37
             $this->entities[$gid] = $entity;
38 38
             foreach ($this->getKeys($entity) as $key) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @param Closure $factory `fn($caller): null|AbstractEntity`
53 53
      * @return null|mixed|AbstractEntity
54 54
      */
55
-    public function get (string $key, $caller, Closure $factory) {
55
+    public function get(string $key, $caller, Closure $factory) {
56 56
         if ($gid = $this->gids[$key] ?? null) {
57 57
             return $this->entities[$gid];
58 58
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @param AbstractEntity $entity
82 82
      * @return string[]
83 83
      */
84
-    protected function getKeys (AbstractEntity $entity) {
84
+    protected function getKeys(AbstractEntity $entity) {
85 85
         if (!$gid = $entity->getGid() or $entity->isDiff()) {
86 86
             return [];
87 87
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      *
98 98
      * @param AbstractEntity $entity
99 99
      */
100
-    public function remove (AbstractEntity $entity): void {
100
+    public function remove(AbstractEntity $entity): void {
101 101
         unset($this->entities[$entity->getGid()]);
102 102
         foreach ($this->getKeys($entity) as $key) {
103 103
             unset($this->gids[$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 $payload
14 14
      */
15
-    public function log (string $info, string $path, ?array $payload): void;
15
+    public function log(string $info, string $path, ?array $payload): void;
16 16
 }
17 17
\ 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
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
 
12 12
     const NAME = 'asana';
13 13
 
14
-    public function boot () {
14
+    public function boot() {
15 15
         $this->mergeConfigFrom(App::configPath('asana.php'), self::NAME);
16 16
     }
17 17
 
18
-    public function register () {
18
+    public function register() {
19 19
         $this->app->singleton(self::NAME, function($app) {
20 20
             $config = $app->config->get(self::NAME);
21 21
             return new Api($config['token']);
Please login to merge, or discard this patch.
src/Api/SimpleCache.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@
 block discarded – undo
68 68
                     /** @var null|AbstractEntity $entity */
69 69
                     if ($entity = $this->get($entity, $caller, $factory)) {
70 70
                         $this->cache->set($key, $entity->getGid()); // renew potentially nonstandard key
71
-                    }
72
-                    else {
71
+                    } else {
73 72
                         $this->cache->delete($key); // remove invalid key
74 73
                     }
75 74
                     return $entity; // null or hydrated. parent calls add()
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * @param Api $api
37 37
      * @param PSR16 $cache
38 38
      */
39
-    public function __construct (Api $api, PSR16 $cache) {
39
+    public function __construct(Api $api, PSR16 $cache) {
40 40
         $this->api = $api;
41 41
         $this->cache = $cache;
42 42
     }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      * @param AbstractEntity $entity
46 46
      * @throws InvalidArgumentException
47 47
      */
48
-    public function add (AbstractEntity $entity): void {
48
+    public function add(AbstractEntity $entity): void {
49 49
         if ($gid = $entity->getGid() and !$entity->isDiff()) {
50 50
             parent::add($entity);
51 51
             foreach ($this->getKeys($entity) as $key) {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         }
58 58
     }
59 59
 
60
-    public function get (string $key, $caller, Closure $factory) {
60
+    public function get(string $key, $caller, Closure $factory) {
61 61
         return parent::get($key, $caller, function($caller) use ($key, $factory) {
62 62
             /** @var null|string|AbstractEntity $entity */
63 63
             if ($entity = $this->cache->get($key)) { // hit?
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @param Api|Data $caller
102 102
      * @return AbstractEntity
103 103
      */
104
-    protected function hydrate (AbstractEntity $proto, $caller) {
104
+    protected function hydrate(AbstractEntity $proto, $caller) {
105 105
         return $this->api->factory(get_class($proto), $caller, $proto->toArray());
106 106
     }
107 107
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      * @param AbstractEntity $entity
110 110
      * @throws InvalidArgumentException
111 111
      */
112
-    public function remove (AbstractEntity $entity): void {
112
+    public function remove(AbstractEntity $entity): void {
113 113
         parent::remove($entity);
114 114
         $this->cache->deleteMultiple($this->getKeys($entity));
115 115
     }
Please login to merge, or discard this patch.