Completed
Pull Request — master (#15)
by Mohamed
06:36 queued 02:22
created
src/Traits/Collections.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     {
134 134
         $result = [];
135 135
 
136
-        __::doForEach($collection, function ($value, $key, $collection) use (&$result, $iterateFn) {
136
+        __::doForEach($collection, function($value, $key, $collection) use (&$result, $iterateFn) {
137 137
             $result[] = $iterateFn($value, $key, $collection);
138 138
         });
139 139
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      */
191 191
     public static function pluck($collection, string $property): array
192 192
     {
193
-        $result = array_map(function ($value) use ($property) {
193
+        $result = array_map(function($value) use ($property) {
194 194
             if (is_array($value) && isset($value[$property])) {
195 195
                 return $value[$property];
196 196
             } elseif (is_object($value) && isset($value->{$property})) {
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             }
214 214
 
215 215
             return $value;
216
-        }, (array)$collection);
216
+        }, (array) $collection);
217 217
 
218 218
         return array_values($result);
219 219
     }
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
      */
285 285
     public static function assign($collection1, $collection2)
286 286
     {
287
-        return __::reduceRight(func_get_args(), function ($source, $result) {
288
-            __::doForEach($source, function ($sourceValue, $key) use (&$result) {
287
+        return __::reduceRight(func_get_args(), function($source, $result) {
288
+            __::doForEach($source, function($sourceValue, $key) use (&$result) {
289 289
                 $result = __::set($result, $key, $sourceValue);
290 290
             });
291 291
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 
324 324
         __::doForEachRight(
325 325
             $collection,
326
-            function ($value, $key, $collection) use (&$accumulator, $iterateFn) {
326
+            function($value, $key, $collection) use (&$accumulator, $iterateFn) {
327 327
                 $accumulator = $iterateFn($accumulator, $value, $key, $collection);
328 328
             }
329 329
         );
@@ -441,13 +441,13 @@  discard block
 block discarded – undo
441 441
      */
442 442
     public static function universalSet($collection, $key, $value)
443 443
     {
444
-        $set_object = function ($object, $key, $value) {
444
+        $set_object = function($object, $key, $value) {
445 445
             $newObject = clone $object;
446 446
             $newObject->$key = $value;
447 447
 
448 448
             return $newObject;
449 449
         };
450
-        $set_array = function ($array, $key, $value) {
450
+        $set_array = function($array, $key, $value) {
451 451
             $array[$key] = $value;
452 452
 
453 453
             return $array;
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
         }
479 479
 
480 480
         return __::every(
481
-            __::map($keys, function ($key) use ($collection) {
481
+            __::map($keys, function($key) use ($collection) {
482 482
                 return __::has($collection, $key);
483 483
             }),
484
-            function ($v) {
484
+            function($v) {
485 485
                 return $v === true;
486 486
             }
487 487
         );
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         $key = $portions[0];
510 510
 
511 511
         if (count($portions) === 1) {
512
-            return array_key_exists($key, (array)$collection);
512
+            return array_key_exists($key, (array) $collection);
513 513
         }
514 514
 
515 515
         return __::has(__::get($collection, $key), $portions[1]);
@@ -535,13 +535,13 @@  discard block
 block discarded – undo
535 535
     {
536 536
         $isObject = __::isObject($collection1);
537 537
 
538
-        $args = __::map(func_get_args(), function ($arg) {
539
-            return (array)$arg;
538
+        $args = __::map(func_get_args(), function($arg) {
539
+            return (array) $arg;
540 540
         });
541 541
 
542 542
         $merged = call_user_func_array('array_merge', $args);
543 543
 
544
-        return $isObject ? (object)$merged : $merged;
544
+        return $isObject ? (object) $merged : $merged;
545 545
     }
546 546
 
547 547
     /**
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
      */
564 564
     public static function concatDeep($collection1, $collection2)
565 565
     {
566
-        return __::reduceRight(func_get_args(), function ($source, $result) {
567
-            __::doForEach($source, function ($sourceValue, $key) use (&$result) {
566
+        return __::reduceRight(func_get_args(), function($source, $result) {
567
+            __::doForEach($source, function($sourceValue, $key) use (&$result) {
568 568
                 if (!__::has($result, $key)) {
569 569
                     $result = __::set($result, $key, $sourceValue);
570 570
                 } else {
@@ -573,8 +573,8 @@  discard block
 block discarded – undo
573 573
                     } else {
574 574
                         $resultValue = __::get($result, $key);
575 575
                         $result = __::set($result, $key, __::concatDeep(
576
-                            __::isCollection($resultValue) ? $resultValue : (array)$resultValue,
577
-                            __::isCollection($sourceValue) ? $sourceValue : (array)$sourceValue
576
+                            __::isCollection($resultValue) ? $resultValue : (array) $resultValue,
577
+                            __::isCollection($sourceValue) ? $sourceValue : (array) $sourceValue
578 578
                         ));
579 579
                     }
580 580
                 }
@@ -615,9 +615,9 @@  discard block
 block discarded – undo
615 615
     {
616 616
         foreach ($array as $index => $value) {
617 617
             if (is_array($value)) {
618
-                __::internalEase($map, $value, $glue, $prefix . $index . $glue);
618
+                __::internalEase($map, $value, $glue, $prefix.$index.$glue);
619 619
             } else {
620
-                $map[$prefix . $index] = $value;
620
+                $map[$prefix.$index] = $value;
621 621
             }
622 622
         }
623 623
     }
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 
643 643
         __::doForEach(
644 644
             $collection,
645
-            function ($value, $key, $collection) use (&$truthy, $iterateFn) {
645
+            function($value, $key, $collection) use (&$truthy, $iterateFn) {
646 646
                 $truthy = $truthy && $iterateFn($value, $key, $collection);
647 647
                 if (!$truthy) {
648 648
                     return false;
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
             $groupKey = null;
710 710
             if (is_callable($key)) {
711 711
                 $groupKey = call_user_func($key, $value);
712
-            } elseif (is_object($value) && property_exists($value, (string)$key)) {
712
+            } elseif (is_object($value) && property_exists($value, (string) $key)) {
713 713
                 $groupKey = $value->{$key};
714 714
             } elseif (is_array($value) && isset($value[$key])) {
715 715
                 $groupKey = $value[$key];
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
      */
743 743
     public static function isEmpty($value): bool
744 744
     {
745
-        return (!__::isArray($value) && !__::isObject($value)) || count((array)$value) === 0;
745
+        return (!__::isArray($value) && !__::isObject($value)) || count((array) $value) === 0;
746 746
     }
747 747
 
748 748
     /**
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
      */
814 814
     public static function merge($collection1, $collection2)
815 815
     {
816
-        return __::reduceRight(func_get_args(), function ($source, $result) {
817
-            __::doForEach($source, function ($sourceValue, $key) use (&$result) {
816
+        return __::reduceRight(func_get_args(), function($source, $result) {
817
+            __::doForEach($source, function($sourceValue, $key) use (&$result) {
818 818
                 $value = $sourceValue;
819 819
                 if (__::isCollection($value)) {
820 820
                     $value = __::merge(__::get($result, $key), $sourceValue);
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
      */
842 842
     public static function pick($collection = [], array $paths = [], $default = null)
843 843
     {
844
-        return __::reduce($paths, function ($results, $path) use ($collection, $default) {
844
+        return __::reduce($paths, function($results, $path) use ($collection, $default) {
845 845
             return __::set($results, $path, __::get($collection, $path, $default));
846 846
         }, __::isObject($collection) ? new stdClass() : []);
847 847
     }
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
         }
913 913
         __::doForEach(
914 914
             $collection,
915
-            function ($value, $key, $collection) use (&$accumulator, $iterateFn) {
915
+            function($value, $key, $collection) use (&$accumulator, $iterateFn) {
916 916
                 $accumulator = $iterateFn($accumulator, $value, $key, $collection);
917 917
             }
918 918
         );
Please login to merge, or discard this patch.
src/Traits/Strings.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 
45 45
         return array_reduce(
46 46
             $words,
47
-            function ($result, $word) use ($words) {
47
+            function($result, $word) use ($words) {
48 48
                 $isFirst = __::first($words) === $word;
49 49
                 $word = __::toLower($word);
50 50
 
51
-                return $result . (!$isFirst ? __::capitalize($word) : $word);
51
+                return $result.(!$isFirst ? __::capitalize($word) : $word);
52 52
             },
53 53
             ''
54 54
         );
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 
88 88
         return array_reduce(
89 89
             $words,
90
-            function ($result, $word) use ($words) {
90
+            function($result, $word) use ($words) {
91 91
                 $isFirst = __::first($words) === $word;
92 92
 
93
-                return $result . (!$isFirst ? '-' : '') . __::toLower($word);
93
+                return $result.(!$isFirst ? '-' : '').__::toLower($word);
94 94
             },
95 95
             ''
96 96
         );
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
 
130 130
         return array_reduce(
131 131
             $words,
132
-            function ($result, $word) use ($words) {
132
+            function($result, $word) use ($words) {
133 133
                 $isFirst = __::first($words) === $word;
134 134
 
135
-                return $result . (!$isFirst ? '_' : '') . __::toLower($word);
135
+                return $result.(!$isFirst ? '_' : '').__::toLower($word);
136 136
             },
137 137
             ''
138 138
         );
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
 
157 157
         return array_reduce(
158 158
             $words,
159
-            function ($result, $word) use ($words) {
159
+            function($result, $word) use ($words) {
160 160
                 $isFirst = __::first($words) === $word;
161 161
 
162
-                return $result . (!$isFirst ? ' ' : '') . __::upperFirst($word);
162
+                return $result.(!$isFirst ? ' ' : '').__::upperFirst($word);
163 163
             },
164 164
             ''
165 165
         );
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 
212 212
         return array_reduce(
213 213
             $words,
214
-            function ($result, $word) use ($words) {
214
+            function($result, $word) use ($words) {
215 215
                 $isFirst = __::first($words) === $word;
216 216
 
217
-                return $result . (!$isFirst ? ' ' : '') . __::toUpper($word);
217
+                return $result.(!$isFirst ? ' ' : '').__::toUpper($word);
218 218
             },
219 219
             ''
220 220
         );
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         $rsComboMarksRange = '\x{0300}-\x{036f}';
257 257
         $reComboHalfMarksRange = '\x{fe20}-\x{fe2f}';
258 258
         $rsComboSymbolsRange = '\x{20d0}-\x{20ff}';
259
-        $rsComboRange = $rsComboMarksRange . $reComboHalfMarksRange . $rsComboSymbolsRange;
259
+        $rsComboRange = $rsComboMarksRange.$reComboHalfMarksRange.$rsComboSymbolsRange;
260 260
         $rsDingbatRange = '\x{2700}-\x{27bf}';
261 261
         $rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff';
262 262
         $rsMathOpRange = '\\xac\\xb1\\xd7\\xf7';
@@ -265,57 +265,57 @@  discard block
 block discarded – undo
265 265
         $rsSpaceRange = ' \\t\\x0b\\f\\xa0\x{feff}\\n\\r\x{2028}\x{2029}\x{1680}\x{180e}\x{2000}\x{2001}\x{2002}\x{2003}\x{2004}\x{2005}\x{2006}\x{2007}\x{2008}\x{2009}\x{200a}\x{202f}\x{205f}\x{3000}';
266 266
         $rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde';
267 267
         $rsVarRange = '\x{fe0e}\x{fe0f}';
268
-        $rsBreakRange = $rsMathOpRange . $rsNonCharRange . $rsPunctuationRange . $rsSpaceRange;
268
+        $rsBreakRange = $rsMathOpRange.$rsNonCharRange.$rsPunctuationRange.$rsSpaceRange;
269 269
         /** Used to compose unicode capture groups. */
270 270
         $rsApos = "['\x{2019}]";
271
-        $rsBreak = '[' . $rsBreakRange . ']';
272
-        $rsCombo = '[' . $rsComboRange . ']';
271
+        $rsBreak = '['.$rsBreakRange.']';
272
+        $rsCombo = '['.$rsComboRange.']';
273 273
         $rsDigits = '\\d+';
274
-        $rsDingbat = '[' . $rsDingbatRange . ']';
275
-        $rsLower = '[' . $rsLowerRange . ']';
276
-        $rsMisc = '[^' . $rsAstralRange . $rsBreakRange . $rsDigits . $rsDingbatRange . $rsLowerRange . $rsUpperRange . ']';
274
+        $rsDingbat = '['.$rsDingbatRange.']';
275
+        $rsLower = '['.$rsLowerRange.']';
276
+        $rsMisc = '[^'.$rsAstralRange.$rsBreakRange.$rsDigits.$rsDingbatRange.$rsLowerRange.$rsUpperRange.']';
277 277
         $rsFitz = '\\x{e83c}[\x{effb}-\x{efff}]';
278
-        $rsModifier = '(?:' . $rsCombo . '|' . $rsFitz . ')';
279
-        $rsNonAstral = '[^' . $rsAstralRange . ']';
278
+        $rsModifier = '(?:'.$rsCombo.'|'.$rsFitz.')';
279
+        $rsNonAstral = '[^'.$rsAstralRange.']';
280 280
         $rsRegional = '(?:\x{e83c}[\x{ede6}-\x{edff}]){2}';
281 281
         $rsSurrPair = '[\x{e800}-\x{ebff}][\x{ec00}-\x{efff}]';
282
-        $rsUpper = '[' . $rsUpperRange . ']';
282
+        $rsUpper = '['.$rsUpperRange.']';
283 283
         $rsZWJ = '\x{200d}';
284 284
         /** Used to compose unicode regexes. */
285
-        $rsMiscLower = '(?:' . $rsLower . '|' . $rsMisc . ')';
286
-        $rsMiscUpper = '(?:' . $rsUpper . '|' . $rsMisc . ')';
287
-        $rsOptContrLower = '(?:' . $rsApos . '(?:d|ll|m|re|s|t|ve))?';
288
-        $rsOptContrUpper = '(?:' . $rsApos . '(?:D|LL|M|RE|S|T|VE))?';
289
-        $reOptMod = $rsModifier . '?';
290
-        $rsOptVar = '[' . $rsVarRange . ']?';
285
+        $rsMiscLower = '(?:'.$rsLower.'|'.$rsMisc.')';
286
+        $rsMiscUpper = '(?:'.$rsUpper.'|'.$rsMisc.')';
287
+        $rsOptContrLower = '(?:'.$rsApos.'(?:d|ll|m|re|s|t|ve))?';
288
+        $rsOptContrUpper = '(?:'.$rsApos.'(?:D|LL|M|RE|S|T|VE))?';
289
+        $reOptMod = $rsModifier.'?';
290
+        $rsOptVar = '['.$rsVarRange.']?';
291 291
         $rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)';
292 292
         $rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)';
293 293
         $asciiWords = '/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/';
294 294
         $hasUnicodeWordRegex = '/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/';
295
-        $rsOptJoin = '(?:' . $rsZWJ . '(?:' . join(
295
+        $rsOptJoin = '(?:'.$rsZWJ.'(?:'.join(
296 296
             '|',
297 297
             [$rsNonAstral, $rsRegional, $rsSurrPair]
298
-        ) . ')' . $rsOptVar . $reOptMod . ')*';
299
-        $rsSeq = $rsOptVar . $reOptMod . $rsOptJoin;
300
-        $rsEmoji = '(?:' . join('|', [$rsDingbat, $rsRegional, $rsSurrPair]) . ')' . $rsSeq;
298
+        ).')'.$rsOptVar.$reOptMod.')*';
299
+        $rsSeq = $rsOptVar.$reOptMod.$rsOptJoin;
300
+        $rsEmoji = '(?:'.join('|', [$rsDingbat, $rsRegional, $rsSurrPair]).')'.$rsSeq;
301 301
 
302 302
         /** @var string $unicodeWords unicode words patterns to be used in preg_match */
303
-        $unicodeWords = '/' . join('|', [
304
-                $rsUpper . '?' . $rsLower . '+' . $rsOptContrLower . '(?=' . join(
303
+        $unicodeWords = '/'.join('|', [
304
+                $rsUpper.'?'.$rsLower.'+'.$rsOptContrLower.'(?='.join(
305 305
                     '|',
306 306
                     [$rsBreak, $rsUpper, '$']
307
-                ) . ')',
308
-                $rsMiscUpper . '+' . $rsOptContrUpper . '(?=' . join(
307
+                ).')',
308
+                $rsMiscUpper.'+'.$rsOptContrUpper.'(?='.join(
309 309
                     '|',
310
-                    [$rsBreak, $rsUpper . $rsMiscLower, '$']
311
-                ) . ')',
312
-                $rsUpper . '?' . $rsMiscLower . '+' . $rsOptContrLower,
313
-                $rsUpper . '+' . $rsOptContrUpper,
310
+                    [$rsBreak, $rsUpper.$rsMiscLower, '$']
311
+                ).')',
312
+                $rsUpper.'?'.$rsMiscLower.'+'.$rsOptContrLower,
313
+                $rsUpper.'+'.$rsOptContrUpper,
314 314
                 $rsOrdUpper,
315 315
                 $rsOrdLower,
316 316
                 $rsDigits,
317 317
                 $rsEmoji,
318
-            ]) . '/u';
318
+            ]).'/u';
319 319
         if ($pattern === null) {
320 320
             $hasUnicodeWord = preg_match($hasUnicodeWordRegex, $input);
321 321
             $pattern = $hasUnicodeWord ? $unicodeWords : $asciiWords;
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 
345 345
         return array_reduce(
346 346
             $words,
347
-            function ($result, $word) use ($words) {
347
+            function($result, $word) use ($words) {
348 348
                 $isFirst = __::first($words) === $word;
349 349
 
350
-                return $result . (!$isFirst ? ' ' : '') . __::toLower($word);
350
+                return $result.(!$isFirst ? ' ' : '').__::toLower($word);
351 351
             },
352 352
             ''
353 353
         );
Please login to merge, or discard this patch.