Passed
Pull Request — develop (#27)
by Glynn
03:53 queued 27s
created
src/general.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@
 block discarded – undo
264 264
  * Only works for public or dynamic properties.
265 265
  *
266 266
  * @param array<string,mixed>|ArrayObject<string,mixed>|object $store
267
-     * @param string $property The property key.
267
+ * @param string $property The property key.
268 268
  * @return Closure(mixed):(array<string,mixed>|ArrayObject<string,mixed>|object)
269 269
  */
270 270
 function setProperty($store, string $property): Closure
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @param mixed The value passed into the functions
49 49
      * @return mixed The final result.
50 50
      */
51
-    return function ($e) use ($callables) {
51
+    return function($e) use ($callables) {
52 52
         foreach ($callables as $callable) {
53 53
             $e = $callable($e);
54 54
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @param mixed The value passed into the functions
70 70
      * @return mixed The final result.
71 71
      */
72
-    return function ($e) use ($callables) {
72
+    return function($e) use ($callables) {
73 73
         foreach (\array_reverse($callables) as $callable) {
74 74
             $e = $callable($e);
75 75
         }
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
      * @param mixed The value passed into the functions
91 91
      * @return mixed|null The final result or null.
92 92
      */
93
-    return function ($e) use ($callables) {
93
+    return function($e) use ($callables) {
94 94
         foreach ($callables as $callable) {
95
-            if (! is_null($e)) {
95
+            if (!is_null($e)) {
96 96
                 $e = $callable($e);
97 97
             }
98 98
         }
@@ -115,17 +115,17 @@  discard block
 block discarded – undo
115 115
      * @param mixed $e The value being passed through the functions.
116 116
      * @return mixed The final result.
117 117
      */
118
-    return function ($e) use ($validator, $callables) {
118
+    return function($e) use ($validator, $callables) {
119 119
         foreach ($callables as $callable) {
120 120
             // If invalid, abort and return null
121
-            if (! $validator($e)) {
121
+            if (!$validator($e)) {
122 122
                 return null;
123 123
             }
124 124
             // Run through callable.
125 125
             $e = $callable($e);
126 126
 
127 127
             // Check results and bail if invalid type.
128
-            if (! $validator($e)) {
128
+            if (!$validator($e)) {
129 129
                 return null;
130 130
             }
131 131
         }
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
      * @param mixed $data The array or object to attempt to get param.
172 172
      * @return mixed|null
173 173
      */
174
-    return function ($data) use ($property) {
174
+    return function($data) use ($property) {
175 175
         if (is_array($data)) {
176
-            return array_key_exists($property, $data) ? $data[ $property ] : null;
176
+            return array_key_exists($property, $data) ? $data[$property] : null;
177 177
         } elseif (is_object($data)) {
178 178
             return property_exists($data, $property) ? $data->{$property} : null;
179 179
         } else {
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      * @param mixed[]|object $data The array or object to attempt to get param.
197 197
      * @return mixed|null
198 198
      */
199
-    return function ($data) use ($nodes) {
199
+    return function($data) use ($nodes) {
200 200
         foreach ($nodes as $node) {
201 201
             $data = getProperty($node)($data);
202 202
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      * @param mixed $data The array or object to attempt to get param.
222 222
      * @return mixed|null
223 223
      */
224
-    return function ($data) use ($property): bool {
224
+    return function($data) use ($property): bool {
225 225
         if (is_array($data)) {
226 226
             return array_key_exists($property, $data);
227 227
         } elseif (is_object($data)) {
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      * @param mixed $data The array or object to attempt to get param.
247 247
      * @return bool
248 248
      */
249
-    return function ($data) use ($property, $value): bool {
249
+    return function($data) use ($property, $value): bool {
250 250
         return pipe(
251 251
             $data,
252 252
             getProperty($property),
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 {
272 272
 
273 273
     // If passed store is not an array or object, throw exception.
274
-    if (! isArrayAccess($store) && ! is_object($store)) {
274
+    if (!isArrayAccess($store) && !is_object($store)) {
275 275
         throw new TypeError('Only objects or arrays can be constructed using setProperty.');
276 276
     }
277 277
 
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
      * @param mixed $value The value to set to keu.
280 280
      * @return array<string,mixed>|ArrayObject<string,mixed>|object The datastore.
281 281
      */
282
-    return function ($value) use ($store, $property) {
282
+    return function($value) use ($store, $property) {
283 283
         if (isArrayAccess($store)) {
284 284
             /** @phpstan-ignore-next-line */
285
-            $store[ $property ] = $value;
285
+            $store[$property] = $value;
286 286
         } else {
287 287
             $store->{$property} = $value;
288 288
         }
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
      * @param mixed $data The data to pass through the callable
306 306
      * @return array
307 307
      */
308
-    return function ($data) use ($key, $value): array {
309
-        return array( $key => $value($data) );
308
+    return function($data) use ($key, $value): array {
309
+        return array($key => $value($data));
310 310
     };
311 311
 }
312 312
 
@@ -323,12 +323,12 @@  discard block
 block discarded – undo
323 323
      * @param callable(mixed):mixed ...$encoders encodeProperty() functions.
324 324
      * @return Closure
325 325
      */
326
-    return function (...$encoders) use ($dataType): Closure {
326
+    return function(...$encoders) use ($dataType): Closure {
327 327
         /**
328 328
          * @param mixed $data The data to pass through the encoders.
329 329
          * @return array<string,mixed>|object The encoded object/array.
330 330
          */
331
-        return function ($data) use ($dataType, $encoders) {
331
+        return function($data) use ($dataType, $encoders) {
332 332
             foreach ($encoders as $encoder) {
333 333
                 $key = array_keys($encoder($data))[0];
334 334
                 // throw exception if key is int
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
      * @param mixed ...$args
356 356
      * @return mixed
357 357
      */
358
-    return function (...$args) use ($fn) {
358
+    return function(...$args) use ($fn) {
359 359
         return $fn(...$args);
360 360
     };
361 361
 }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
      * @param mixed $ignored Any values can be passed and ignored.
373 373
      * @return mixed
374 374
      */
375
-    return function (...$ignored) use ($value) {
375
+    return function(...$ignored) use ($value) {
376 376
         return $value;
377 377
     };
378 378
 }
@@ -389,18 +389,18 @@  discard block
 block discarded – undo
389 389
      * @param object $object
390 390
      * @return array<string, mixed>
391 391
      */
392
-    return function ($object): array {
392
+    return function($object): array {
393 393
 
394 394
         // If not object, return empty array.
395
-        if (! is_object($object)) {
395
+        if (!is_object($object)) {
396 396
             return array();
397 397
         }
398 398
 
399 399
         $objectVars = get_object_vars($object);
400 400
         return array_reduce(
401 401
             array_keys($objectVars),
402
-            function (array $array, $key) use ($objectVars): array {
403
-                $array[ ltrim((string) $key, '_') ] = $objectVars[ $key ];
402
+            function(array $array, $key) use ($objectVars): array {
403
+                $array[ltrim((string) $key, '_')] = $objectVars[$key];
404 404
                 return $array;
405 405
             },
406 406
             array()
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
      * @param  mixed $value
423 423
      * @return mixed
424 424
      */
425
-    return function ($value) use ($condition, $then) {
425
+    return function($value) use ($condition, $then) {
426 426
         return true === (bool) $condition($value)
427 427
             ? $then($value)
428 428
             : $value;
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
      * @param  mixed $value
446 446
      * @return mixed
447 447
      */
448
-    return function ($value) use ($condition, $then, $else) {
448
+    return function($value) use ($condition, $then, $else) {
449 449
         return true === (bool) $condition($value)
450 450
             ? $then($value)
451 451
             : $else($value);
Please login to merge, or discard this patch.
src/objects.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     if (is_object($class)) {
53 53
         $class = get_class($class);
54 54
     }
55
-    if (! class_exists($class)) {
55
+    if (!class_exists($class)) {
56 56
         throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Class or Class Name');
57 57
     }
58 58
 
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
      * @param Class $value
61 61
      * @return bool
62 62
      */
63
-    return function ($value) use ($class): bool {
63
+    return function($value) use ($class): bool {
64 64
         if (is_object($value)) {
65 65
             $value = get_class($value);
66 66
         }
67
-        if (! class_exists($value)) {
67
+        if (!class_exists($value)) {
68 68
             throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Class or Class Name');
69 69
         }
70 70
         return is_a($value, $class, true);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @param Class $class
85 85
      * @return bool
86 86
      */
87
-    return function ($class) use ($interface): bool {
87
+    return function($class) use ($interface): bool {
88 88
         return in_array(
89 89
             $class,
90 90
             class_implements($interface, false) ?: array(),
Please login to merge, or discard this patch.
src/numbers.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param int|null $value
47 47
      * @return Closure(int|null):(Closure|int)|int
48 48
      */
49
-    return function (?int $value = null) use ($initial) {
49
+    return function(?int $value = null) use ($initial) {
50 50
         if ($value) {
51 51
             $initial += $value;
52 52
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @param float|null $value
67 67
      * @return Closure(float|null):(Closure|float)|float
68 68
      */
69
-    return function (?float $value = null) use ($initial) {
69
+    return function(?float $value = null) use ($initial) {
70 70
         if ($value) {
71 71
             $initial += $value;
72 72
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
  */
84 84
 function sum($initial = 0): Closure
85 85
 {
86
-    if (! C\isNumber($initial)) {
86
+    if (!C\isNumber($initial)) {
87 87
         throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
88 88
     }
89 89
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @param Number $value
92 92
      * @return int|float
93 93
      */
94
-    return function ($value) use ($initial) {
94
+    return function($value) use ($initial) {
95 95
         return $initial + $value;
96 96
     };
97 97
 }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  */
107 107
 function subtract($initial = 0): Closure
108 108
 {
109
-    if (! C\isNumber($initial)) {
109
+    if (!C\isNumber($initial)) {
110 110
         throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
111 111
     }
112 112
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      * @param Number $value
115 115
      * @return int|float
116 116
      */
117
-    return function ($value) use ($initial) {
117
+    return function($value) use ($initial) {
118 118
         return $value - $initial;
119 119
     };
120 120
 }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
  */
130 130
 function multiply($initial = 1): Closure
131 131
 {
132
-    if (! C\isNumber($initial)) {
132
+    if (!C\isNumber($initial)) {
133 133
         throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
134 134
     }
135 135
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      * @param Number $value
138 138
      * @return Number
139 139
      */
140
-    return function ($value) use ($initial) {
140
+    return function($value) use ($initial) {
141 141
         return $value * $initial;
142 142
     };
143 143
 }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
  */
154 154
 function divideBy($divisor = 1): Closure
155 155
 {
156
-    if (! C\isNumber($divisor)) {
156
+    if (!C\isNumber($divisor)) {
157 157
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
158 158
     }
159 159
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      * @param float $value
162 162
      * @return float
163 163
      */
164
-    return function ($value) use ($divisor): float {
164
+    return function($value) use ($divisor): float {
165 165
         return $value / $divisor;
166 166
     };
167 167
 }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
  */
176 176
 function divideInto($dividend = 1): Closure
177 177
 {
178
-    if (! C\isNumber($dividend)) {
178
+    if (!C\isNumber($dividend)) {
179 179
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
180 180
     }
181 181
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      * @param float $value
184 184
      * @return float
185 185
      */
186
-    return function ($value) use ($dividend): float {
186
+    return function($value) use ($dividend): float {
187 187
         return $dividend / $value;
188 188
     };
189 189
 }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
  */
198 198
 function remainderBy($divisor = 1): Closure
199 199
 {
200
-    if (! C\isNumber($divisor)) {
200
+    if (!C\isNumber($divisor)) {
201 201
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
202 202
     }
203 203
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      * @param float $value
206 206
      * @return float
207 207
      */
208
-    return function ($value) use ($divisor): float {
208
+    return function($value) use ($divisor): float {
209 209
         return $value % $divisor;
210 210
     };
211 211
 }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
  */
220 220
 function remainderInto($dividend = 1): Closure
221 221
 {
222
-    if (! C\isNumber($dividend)) {
222
+    if (!C\isNumber($dividend)) {
223 223
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
224 224
     }
225 225
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      * @param float $value
228 228
      * @return float
229 229
      */
230
-    return function ($value) use ($dividend): float {
230
+    return function($value) use ($dividend): float {
231 231
         return $dividend % $value;
232 232
     };
233 233
 }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  */
242 242
 function isMultipleOf($factor): Closure
243 243
 {
244
-    if (! C\isNumber($factor)) {
244
+    if (!C\isNumber($factor)) {
245 245
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
246 246
     }
247 247
 
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
      * @return bool
251 251
      * @throws InvalidArgumentException If neither int or float passed.
252 252
      */
253
-    return function ($value) use ($factor): bool {
254
-        if (! C\isNumber($value)) {
253
+    return function($value) use ($factor): bool {
254
+        if (!C\isNumber($value)) {
255 255
             throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
256 256
         }
257 257
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
  */
275 275
 function round($precision = 1): Closure
276 276
 {
277
-    if (! C\isNumber($precision)) {
277
+    if (!C\isNumber($precision)) {
278 278
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
279 279
     }
280 280
 
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
      * @return float
284 284
      * @throws InvalidArgumentException If neither int or float passed.
285 285
      */
286
-    return function ($value) use ($precision): float {
287
-        if (! C\isNumber($value)) {
286
+    return function($value) use ($precision): float {
287
+        if (!C\isNumber($value)) {
288 288
             throw new \InvalidArgumentException("Num\\round() only accepts a valid Number ( Int|Float -> Float )");
289 289
         }
290 290
         return \round(\floatval($value), $precision);
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
  */
301 301
 function power($exponent): Closure
302 302
 {
303
-    if (! C\isNumber($exponent)) {
303
+    if (!C\isNumber($exponent)) {
304 304
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int) for the exponent');
305 305
     }
306 306
 
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
      * @return Number
310 310
      * @throws InvalidArgumentException If neither int or float passed.
311 311
      */
312
-    return function ($value) use ($exponent) {
313
-        if (! C\isNumber($value)) {
312
+    return function($value) use ($exponent) {
313
+        if (!C\isNumber($value)) {
314 314
             throw new \InvalidArgumentException('Num\\power() only accepts a valid Number ( Int|Float )');
315 315
         }
316 316
         return \pow($value, $exponent);
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
  */
327 327
 function root($root): Closure
328 328
 {
329
-    if (! C\isNumber($root)) {
329
+    if (!C\isNumber($root)) {
330 330
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int) for the root');
331 331
     }
332 332
 
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
      * @return Number
336 336
      * @throws InvalidArgumentException If neither int or float passed.
337 337
      */
338
-    return function ($value) use ($root) {
339
-        if (! C\isNumber($value)) {
338
+    return function($value) use ($root) {
339
+        if (!C\isNumber($value)) {
340 340
             throw new \InvalidArgumentException('Num\\root() only accepts a valid Number ( Int|Float )');
341 341
         }
342 342
         return pow($value, (1 / $root));
Please login to merge, or discard this patch.