Passed
Branch master (5cd5fb)
by y
01:48
created
src/Event.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
  */
42 42
 class Event extends Data {
43 43
 
44
-    const ACTION_CHANGED = 'changed';       // no parent
45
-    const ACTION_ADDED = 'added';           // relational, no change
46
-    const ACTION_REMOVED = 'removed';       // relational, no change
47
-    const ACTION_DELETED = 'deleted';       // no parent or change
48
-    const ACTION_UNDELETED = 'undeleted';   // no parent or change
44
+    const ACTION_CHANGED = 'changed'; // no parent
45
+    const ACTION_ADDED = 'added'; // relational, no change
46
+    const ACTION_REMOVED = 'removed'; // relational, no change
47
+    const ACTION_DELETED = 'deleted'; // no parent or change
48
+    const ACTION_UNDELETED = 'undeleted'; // no parent or change
49 49
 
50 50
     const GRAPH = [
51 51
         User::TYPE => User::class,
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         'user' => User::class
64 64
     ];
65 65
 
66
-    protected function _setData (array $data): void {
66
+    protected function _setData(array $data): void {
67 67
         if (isset($data['parent'])) {
68 68
             $type = $data['parent']['resource_type'];
69 69
             $data['parent'] = $this->_hydrate(static::GRAPH[$type], $data['parent']);
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @return null|Project|Section|Task
82 82
      */
83
-    public function getParent () {
83
+    public function getParent() {
84 84
         return $this->data['parent'] ?? null;
85 85
     }
86 86
 
@@ -89,42 +89,42 @@  discard block
 block discarded – undo
89 89
      *
90 90
      * @return User|Project|Section|Task|CustomField|Attachment|Story|Like
91 91
      */
92
-    public function getResource () {
92
+    public function getResource() {
93 93
         return $this->data['resource'];
94 94
     }
95 95
 
96 96
     /**
97 97
      * @return bool
98 98
      */
99
-    final public function wasAddition (): bool {
99
+    final public function wasAddition(): bool {
100 100
         return $this->getAction() === self::ACTION_ADDED;
101 101
     }
102 102
 
103 103
     /**
104 104
      * @return bool
105 105
      */
106
-    final public function wasChange (): bool {
106
+    final public function wasChange(): bool {
107 107
         return $this->getAction() === self::ACTION_CHANGED;
108 108
     }
109 109
 
110 110
     /**
111 111
      * @return bool
112 112
      */
113
-    final public function wasDeletion (): bool {
113
+    final public function wasDeletion(): bool {
114 114
         return $this->getAction() === self::ACTION_DELETED;
115 115
     }
116 116
 
117 117
     /**
118 118
      * @return bool
119 119
      */
120
-    final public function wasRemoval (): bool {
120
+    final public function wasRemoval(): bool {
121 121
         return $this->getAction() === self::ACTION_REMOVED;
122 122
     }
123 123
 
124 124
     /**
125 125
      * @return bool
126 126
      */
127
-    final public function wasUndeletion (): bool {
127
+    final public function wasUndeletion(): bool {
128 128
         return $this->getAction() === self::ACTION_UNDELETED;
129 129
     }
130 130
 }
131 131
\ No newline at end of file
Please login to merge, or discard this patch.
src/Base/Data.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param Api|Data $caller
47 47
      * @param array $data
48 48
      */
49
-    public function __construct ($caller, array $data = []) {
49
+    public function __construct($caller, array $data = []) {
50 50
         if ($caller instanceof self) {
51 51
             $this->api = $caller->api;
52 52
         }
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
      * @param array $args
70 70
      * @return mixed
71 71
      */
72
-    public function __call (string $method, array $args) {
72
+    public function __call(string $method, array $args) {
73 73
         static $magic = [];
74
-        if (!$call =& $magic[$method]) {
74
+        if (!$call = & $magic[$method]) {
75 75
             preg_match('/^(get|has|is|select|set)(.+)$/', $method, $call);
76 76
             if ('_select' !== $call[1] = '_' . $call[1]) { // _select() calls getters
77 77
                 $call[2] = preg_replace_callback('/[A-Z]/', function(array $match) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * @return array
87 87
      * @internal pool, `var_export()`
88 88
      */
89
-    final public function __debugInfo (): array {
89
+    final public function __debugInfo(): array {
90 90
         return $this->data;
91 91
     }
92 92
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      * @return null|Data|mixed
96 96
      * @internal for `array_column()`
97 97
      */
98
-    final public function __get ($field) {
98
+    final public function __get($field) {
99 99
         return $this->_get($field);
100 100
     }
101 101
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @return bool
105 105
      * @internal for `array_column()`
106 106
      */
107
-    final public function __isset ($field) {
107
+    final public function __isset($field) {
108 108
         return true; // fields may be lazy-loaded or coalesced to null.
109 109
     }
110 110
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      * @param string $field
117 117
      * @return mixed
118 118
      */
119
-    protected function _get (string $field) {
119
+    protected function _get(string $field) {
120 120
         return $this->data[$field] ?? null;
121 121
     }
122 122
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      * @param string $field
132 132
      * @return bool
133 133
      */
134
-    protected function _has (string $field): bool {
134
+    protected function _has(string $field): bool {
135 135
         $value = $this->_get($field);
136 136
         if (isset($value)) {
137 137
             if (is_countable($value)) {
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      * @param mixed $item
150 150
      * @return mixed
151 151
      */
152
-    protected function _hydrate (string $class, $item) {
152
+    protected function _hydrate(string $class, $item) {
153 153
         if (!isset($item) or $item instanceof self) {
154 154
             return $item;
155 155
         }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      * @param string $field
179 179
      * @return bool
180 180
      */
181
-    protected function _is (string $field): bool {
181
+    protected function _is(string $field): bool {
182 182
         return (bool)$this->_get($field);
183 183
     }
184 184
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      * @param array $args
197 197
      * @return array
198 198
      */
199
-    protected function _select ($subject, callable $filter, ...$args) {
199
+    protected function _select($subject, callable $filter, ...$args) {
200 200
         if (is_string($subject)) {
201 201
             $subject = $this->{'get' . $subject}(...$args) ?? [];
202 202
         }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      * @param mixed $value
219 219
      * @return $this
220 220
      */
221
-    protected function _set (string $field, $value) {
221
+    protected function _set(string $field, $value) {
222 222
         $this->data[$field] = $value;
223 223
         $this->diff[$field] = true;
224 224
         return $this;
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
      *
230 230
      * @param array $data
231 231
      */
232
-    protected function _setData (array $data): void {
232
+    protected function _setData(array $data): void {
233 233
         $this->data = $this->diff = [];
234 234
         foreach ($data as $field => $value) {
235 235
             $this->_setField($field, $value);
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      * @param string $field
243 243
      * @param mixed $value
244 244
      */
245
-    protected function _setField (string $field, $value): void {
245
+    protected function _setField(string $field, $value): void {
246 246
         if (isset(static::MAP[$field])) {
247 247
             $class = static::MAP[$field];
248 248
             if (is_array($class)) {
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
      *
264 264
      * @return bool
265 265
      */
266
-    final public function isDiff (): bool {
266
+    final public function isDiff(): bool {
267 267
         return (bool)$this->diff;
268 268
     }
269 269
 
270 270
     /**
271 271
      * @return array
272 272
      */
273
-    public function jsonSerialize (): array {
273
+    public function jsonSerialize(): array {
274 274
         $data = $this->toArray();
275 275
         ksort($data);
276 276
         return $data;
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
      *
282 282
      * @return string
283 283
      */
284
-    public function serialize (): string {
285
-        return json_encode($this, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
284
+    public function serialize(): string {
285
+        return json_encode($this, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
286 286
     }
287 287
 
288 288
     /**
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
      * @param bool $diff
292 292
      * @return array
293 293
      */
294
-    public function toArray (bool $diff = false): array {
294
+    public function toArray(bool $diff = false): array {
295 295
         $dehydrate = function($each) use (&$dehydrate, $diff) {
296 296
             // convert entities to gids
297 297
             if ($each instanceof AbstractEntity and $each->hasGid()) {
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     /**
318 318
      * @param $serialized
319 319
      */
320
-    public function unserialize ($serialized): void {
320
+    public function unserialize($serialized): void {
321 321
         $this->data = json_decode($serialized, true);
322 322
     }
323 323
 }
324 324
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@  discard block
 block discarded – undo
49 49
     public function __construct ($caller, array $data = []) {
50 50
         if ($caller instanceof self) {
51 51
             $this->api = $caller->api;
52
-        }
53
-        else {
52
+        } else {
54 53
             assert($caller instanceof Api);
55 54
             /** @var Api $caller */
56 55
             $this->api = $caller;
@@ -251,8 +250,7 @@  discard block
 block discarded – undo
251 250
                 $value = array_map(function($each) use ($class) {
252 251
                     return $this->_hydrate($class[0], $each);
253 252
                 }, $value);
254
-            }
255
-            elseif (isset($value)) {
253
+            } elseif (isset($value)) {
256 254
                 $value = $this->_hydrate($class, $value);
257 255
             }
258 256
         }
Please login to merge, or discard this patch.
src/Base/AbstractEntity/PostMutatorTrait.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      * @param array $diff
20 20
      * @return $this
21 21
      */
22
-    private function _addWithPost (string $addPath, array $data, string $field, array $diff) {
22
+    private function _addWithPost(string $addPath, array $data, string $field, array $diff) {
23 23
         if ($this->hasGid()) {
24 24
             return $this->_setWithPost($addPath, $data, $field);
25 25
         }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * @param array|Closure $diff An array to diff, or a filter closure.
34 34
      * @return $this
35 35
      */
36
-    private function _removeWithPost (string $rmPath, array $data, string $field, $diff) {
36
+    private function _removeWithPost(string $rmPath, array $data, string $field, $diff) {
37 37
         if ($this->hasGid()) {
38 38
             return $this->_setWithPost($rmPath, $data, $field);
39 39
         }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @return $this
54 54
      * @internal
55 55
      */
56
-    private function _setWithPost (string $path, array $data, string $field, $value = null) {
56
+    private function _setWithPost(string $path, array $data, string $field, $value = null) {
57 57
         if ($this->hasGid()) {
58 58
             /** @var array $remote */
59 59
             $remote = $this->api->post($path, $data, ['fields' => static::OPT_FIELDS[$field] ?? $field]);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,7 @@
 block discarded – undo
36 36
     private function _removeWithPost (string $rmPath, array $data, string $field, $diff) {
37 37
         if ($this->hasGid()) {
38 38
             return $this->_setWithPost($rmPath, $data, $field);
39
-        }
40
-        elseif (is_array($diff)) {
39
+        } elseif (is_array($diff)) {
41 40
             return $this->_set($field, array_values(array_diff($this->data[$field] ?? [], $diff)));
42 41
         }
43 42
         return $this->_set($field, array_values(array_filter($this->data[$field] ?? [], $diff)));
Please login to merge, or discard this patch.
src/Event/Change.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     protected $key;
42 42
 
43
-    protected function _setData (array $data): void {
43
+    protected function _setData(array $data): void {
44 44
         $this->key = [
45 45
             Event::ACTION_ADDED => 'added_value',
46 46
             Event::ACTION_REMOVED => 'removed_value',
@@ -67,35 +67,35 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @return null|User|Project|Section|Task|FieldEntry|Attachment|Story|Like
69 69
      */
70
-    public function getPayload () {
70
+    public function getPayload() {
71 71
         return $this->data[$this->key];
72 72
     }
73 73
 
74 74
     /**
75 75
      * @return bool
76 76
      */
77
-    final public function hasPayload (): bool {
77
+    final public function hasPayload(): bool {
78 78
         return isset($this->data[$this->key]);
79 79
     }
80 80
 
81 81
     /**
82 82
      * @return bool
83 83
      */
84
-    final public function wasAddition (): bool {
84
+    final public function wasAddition(): bool {
85 85
         return $this->getAction() === Event::ACTION_ADDED;
86 86
     }
87 87
 
88 88
     /**
89 89
      * @return bool
90 90
      */
91
-    final public function wasRemoval (): bool {
91
+    final public function wasRemoval(): bool {
92 92
         return $this->getAction() === Event::ACTION_REMOVED;
93 93
     }
94 94
 
95 95
     /**
96 96
      * @return bool
97 97
      */
98
-    final public function wasValue (): bool {
98
+    final public function wasValue(): bool {
99 99
         return $this->getAction() === Event::ACTION_CHANGED;
100 100
     }
101 101
 
Please login to merge, or discard this patch.
src/Base/AbstractEntity/SyncTrait.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      * @param null|string $token Updated to the new token.
25 25
      * @return Event[]
26 26
      */
27
-    public function getEvents (?string &$token) {
27
+    public function getEvents(?string &$token) {
28 28
         try {
29 29
             /** @var array $remote Asana throws 400 for missing entities. */
30 30
             $remote = $this->api->call('GET', 'events?' . http_build_query([
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@
 block discarded – undo
32 32
                     'sync' => $token,
33 33
                     'opt_expand' => 'this'
34 34
                 ]));
35
-        }
36
-        catch (AsanaError $error) {
35
+        } catch (AsanaError $error) {
37 36
             if ($error->is(412)) {
38 37
                 $remote = $error->asResponse();
39 38
                 if (!isset($token)) {
Please login to merge, or discard this patch.
src/Job.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @return bool
42 42
      */
43
-    final public function isActive (): bool {
43
+    final public function isActive(): bool {
44 44
         return $this->getStatus() === self::STATUS_ACTIVE;
45 45
     }
46 46
 
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
      *
50 50
      * @return bool
51 51
      */
52
-    final public function isDone (): bool {
52
+    final public function isDone(): bool {
53 53
         return $this->isSuccessful() or $this->isFailed();
54 54
     }
55 55
 
56 56
     /**
57 57
      * @return bool
58 58
      */
59
-    final public function isDuplicatingProject (): bool {
59
+    final public function isDuplicatingProject(): bool {
60 60
         return $this->getResourceSubtype() === self::TYPE_DUPLICATE_PROJECT;
61 61
     }
62 62
 
63 63
     /**
64 64
      * @return bool
65 65
      */
66
-    final public function isDuplicatingTask (): bool {
66
+    final public function isDuplicatingTask(): bool {
67 67
         return $this->getResourceSubtype() === self::TYPE_DUPLICATE_TASK;
68 68
     }
69 69
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @return bool
74 74
      */
75
-    final public function isFailed (): bool {
75
+    final public function isFailed(): bool {
76 76
         return $this->getStatus() === self::STATUS_FAIL;
77 77
     }
78 78
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @return bool
83 83
      */
84
-    final public function isQueued (): bool {
84
+    final public function isQueued(): bool {
85 85
         return $this->getStatus() === self::STATUS_QUEUED;
86 86
     }
87 87
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      *
91 91
      * @return bool
92 92
      */
93
-    final public function isSuccessful (): bool {
93
+    final public function isSuccessful(): bool {
94 94
         return $this->getStatus() === self::STATUS_SUCCESS;
95 95
     }
96 96
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @param callable $spinner `fn( Job $this ): void`
103 103
      * @return $this
104 104
      */
105
-    public function wait (callable $spinner = null) {
105
+    public function wait(callable $spinner = null) {
106 106
         while (!$this->isDone()) {
107 107
             if ($spinner) {
108 108
                 call_user_func($spinner, $this);
Please login to merge, or discard this patch.
src/User/TaskList.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
      * @param array $filter
37 37
      * @return Traversable|Task[]
38 38
      */
39
-    public function getIterator (array $filter = Task::GET_INCOMPLETE) {
39
+    public function getIterator(array $filter = Task::GET_INCOMPLETE) {
40 40
         return $this->api->loadEach($this, Task::class, "{$this}/tasks", $filter);
41 41
     }
42 42
 
43
-    public function getPoolKeys () {
43
+    public function getPoolKeys() {
44 44
         $keys = parent::getPoolKeys();
45 45
 
46 46
         /** @see User::getTaskList() */
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @param array $filter
58 58
      * @return Task[]
59 59
      */
60
-    public function getTasks (array $filter = Task::GET_INCOMPLETE) {
60
+    public function getTasks(array $filter = Task::GET_INCOMPLETE) {
61 61
         return iterator_to_array($this->getIterator($filter));
62 62
     }
63 63
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @param array $apiFilter Given to the API to reduce network load.
67 67
      * @return Task[]
68 68
      */
69
-    public function selectTasks (callable $filter, array $apiFilter = Task::GET_INCOMPLETE) {
69
+    public function selectTasks(callable $filter, array $apiFilter = Task::GET_INCOMPLETE) {
70 70
         return $this->_select($this->getIterator($apiFilter), $filter);
71 71
     }
72 72
 }
73 73
\ No newline at end of file
Please login to merge, or discard this patch.
src/Tag.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @param array $filter
44 44
      * @return Traversable|Task[]
45 45
      */
46
-    public function getIterator (array $filter = Task::GET_INCOMPLETE) {
46
+    public function getIterator(array $filter = Task::GET_INCOMPLETE) {
47 47
         return $this->api->loadEach($this, Task::class, "{$this}/tasks", $filter);
48 48
     }
49 49
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      * @param array $filter
52 52
      * @return Task[]
53 53
      */
54
-    public function getTasks (array $filter = Task::GET_INCOMPLETE) {
54
+    public function getTasks(array $filter = Task::GET_INCOMPLETE) {
55 55
         return iterator_to_array($this->getIterator($filter));
56 56
     }
57 57
 }
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/AsanaError.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      * @param string $message
27 27
      * @param array $curlInfo
28 28
      */
29
-    public function __construct (int $code, string $message, array $curlInfo) {
29
+    public function __construct(int $code, string $message, array $curlInfo) {
30 30
         parent::__construct($message, $code);
31 31
         $this->curlInfo = $curlInfo;
32 32
     }
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @return array
38 38
      */
39
-    public function asResponse () {
40
-        return json_decode($this->getMessage(), true, JSON_BIGINT_AS_STRING | JSON_THROW_ON_ERROR);
39
+    public function asResponse() {
40
+        return json_decode($this->getMessage(), true, JSON_BIGINT_AS_STRING|JSON_THROW_ON_ERROR);
41 41
     }
42 42
 
43 43
     /**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      *
46 46
      * @return array
47 47
      */
48
-    final public function getCurlInfo (): array {
48
+    final public function getCurlInfo(): array {
49 49
         return $this->curlInfo;
50 50
     }
51 51
 
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
      * @param int $code
54 54
      * @return bool
55 55
      */
56
-    final public function is (int $code): bool {
56
+    final public function is(int $code): bool {
57 57
         return $this->code === $code;
58 58
     }
59 59
 
60 60
     /**
61 61
      * @return bool
62 62
      */
63
-    final public function isCurl (): bool {
63
+    final public function isCurl(): bool {
64 64
         return $this->code < 400;
65 65
     }
66 66
 }
67 67
\ No newline at end of file
Please login to merge, or discard this patch.