Completed
Push — master ( 65928f...2d3df6 )
by Lars
02:13
created
src/Arrayy.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             &&
106 106
             \count(\array_diff_key($this->properties, $data)) > 0
107 107
         ) {
108
-            throw new \InvalidArgumentException('Property mismatch - input: ' . \print_r(\array_keys($data), true) . ' | expected: ' . \print_r(\array_keys($this->properties), true));
108
+            throw new \InvalidArgumentException('Property mismatch - input: '.\print_r(\array_keys($data), true).' | expected: '.\print_r(\array_keys($this->properties), true));
109 109
         }
110 110
 
111 111
         /** @noinspection AlterInForeachInspection */
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 
468 468
                     $this->callAtPath(
469 469
                         $containerPath,
470
-                        static function ($container) use ($lastOffset, &$offsetExists) {
470
+                        static function($container) use ($lastOffset, &$offsetExists) {
471 471
                             $offsetExists = \array_key_exists($lastOffset, $container);
472 472
                         }
473 473
                     );
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 
542 542
                 $this->callAtPath(
543 543
                     \implode($this->pathSeparator, $path),
544
-                    static function (&$offset) use ($pathToUnset) {
544
+                    static function(&$offset) use ($pathToUnset) {
545 545
                         unset($offset[$pathToUnset]);
546 546
                     }
547 547
                 );
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
         }
582 582
 
583 583
         if (\strpos($class, '\\') === 0) {
584
-            $class = '\\' . $class;
584
+            $class = '\\'.$class;
585 585
             if (\class_exists($class)) {
586 586
                 $this->iteratorClass = $class;
587 587
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
             }
590 590
         }
591 591
 
592
-        throw new \InvalidArgumentException('The iterator class does not exist: ' . $class);
592
+        throw new \InvalidArgumentException('The iterator class does not exist: '.$class);
593 593
     }
594 594
 
595 595
     /**
@@ -697,13 +697,13 @@  discard block
 block discarded – undo
697 697
 
698 698
         foreach ($this->getGenerator() as $key => $item) {
699 699
             if ($item instanceof self) {
700
-                $result[$prefix . $key] = $item->appendToEachKey($prefix);
700
+                $result[$prefix.$key] = $item->appendToEachKey($prefix);
701 701
             } elseif (\is_array($item)) {
702
-                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
702
+                $result[$prefix.$key] = self::create($item, $this->iteratorClass, false)
703 703
                     ->appendToEachKey($prefix)
704 704
                     ->toArray();
705 705
             } else {
706
-                $result[$prefix . $key] = $item;
706
+                $result[$prefix.$key] = $item;
707 707
             }
708 708
         }
709 709
 
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
             } elseif (\is_object($item)) {
732 732
                 $result[$key] = $item;
733 733
             } else {
734
-                $result[$key] = $prefix . $item;
734
+                $result[$key] = $prefix.$item;
735 735
             }
736 736
         }
737 737
 
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
     public function clean(): self
883 883
     {
884 884
         return $this->filter(
885
-            static function ($value) {
885
+            static function($value) {
886 886
                 return (bool) $value;
887 887
             }
888 888
         );
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
             return $this->in_array_recursive(
949 949
                 \mb_strtoupper((string) $value),
950 950
                 $this->walk(
951
-                    static function (&$val) {
951
+                    static function(&$val) {
952 952
                         /** @noinspection PhpComposerExtensionStubsInspection */
953 953
                         $val = \mb_strtoupper((string) $val);
954 954
                     },
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
         return \in_array(
963 963
             \mb_strtoupper((string) $value),
964 964
             $this->walk(
965
-                static function (&$val) {
965
+                static function(&$val) {
966 966
                     /** @noinspection PhpComposerExtensionStubsInspection */
967 967
                     $val = \mb_strtoupper((string) $val);
968 968
                 },
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
         // trim all string in the array
1254 1254
         \array_walk(
1255 1255
             $array,
1256
-            static function (&$val) {
1256
+            static function(&$val) {
1257 1257
                 if (\is_string($val)) {
1258 1258
                     $val = \trim($val);
1259 1259
                 }
@@ -1581,40 +1581,40 @@  discard block
 block discarded – undo
1581 1581
         }
1582 1582
 
1583 1583
         $ops = [
1584
-            'eq' => static function ($item, $prop, $value) {
1584
+            'eq' => static function($item, $prop, $value) {
1585 1585
                 return $item[$prop] === $value;
1586 1586
             },
1587
-            'gt' => static function ($item, $prop, $value) {
1587
+            'gt' => static function($item, $prop, $value) {
1588 1588
                 return $item[$prop] > $value;
1589 1589
             },
1590
-            'ge' => static function ($item, $prop, $value) {
1590
+            'ge' => static function($item, $prop, $value) {
1591 1591
                 return $item[$prop] >= $value;
1592 1592
             },
1593
-            'gte' => static function ($item, $prop, $value) {
1593
+            'gte' => static function($item, $prop, $value) {
1594 1594
                 return $item[$prop] >= $value;
1595 1595
             },
1596
-            'lt' => static function ($item, $prop, $value) {
1596
+            'lt' => static function($item, $prop, $value) {
1597 1597
                 return $item[$prop] < $value;
1598 1598
             },
1599
-            'le' => static function ($item, $prop, $value) {
1599
+            'le' => static function($item, $prop, $value) {
1600 1600
                 return $item[$prop] <= $value;
1601 1601
             },
1602
-            'lte' => static function ($item, $prop, $value) {
1602
+            'lte' => static function($item, $prop, $value) {
1603 1603
                 return $item[$prop] <= $value;
1604 1604
             },
1605
-            'ne' => static function ($item, $prop, $value) {
1605
+            'ne' => static function($item, $prop, $value) {
1606 1606
                 return $item[$prop] !== $value;
1607 1607
             },
1608
-            'contains' => static function ($item, $prop, $value) {
1608
+            'contains' => static function($item, $prop, $value) {
1609 1609
                 return \in_array($item[$prop], (array) $value, true);
1610 1610
             },
1611
-            'notContains' => static function ($item, $prop, $value) {
1611
+            'notContains' => static function($item, $prop, $value) {
1612 1612
                 return !\in_array($item[$prop], (array) $value, true);
1613 1613
             },
1614
-            'newer' => static function ($item, $prop, $value) {
1614
+            'newer' => static function($item, $prop, $value) {
1615 1615
                 return \strtotime($item[$prop]) > \strtotime($value);
1616 1616
             },
1617
-            'older' => static function ($item, $prop, $value) {
1617
+            'older' => static function($item, $prop, $value) {
1618 1618
                 return \strtotime($item[$prop]) < \strtotime($value);
1619 1619
             },
1620 1620
         ];
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
         $result = \array_values(
1623 1623
             \array_filter(
1624 1624
                 $this->getArray(),
1625
-                static function ($item) use (
1625
+                static function($item) use (
1626 1626
                     $property,
1627 1627
                     $value,
1628 1628
                     $ops,
@@ -2170,7 +2170,7 @@  discard block
 block discarded – undo
2170 2170
                 \array_uintersect(
2171 2171
                     $this->array,
2172 2172
                     $search,
2173
-                    static function ($a, $b) {
2173
+                    static function($a, $b) {
2174 2174
                         return $a === $b ? 0 : -1;
2175 2175
                     }
2176 2176
                 ),
@@ -2387,13 +2387,13 @@  discard block
 block discarded – undo
2387 2387
         // non recursive
2388 2388
 
2389 2389
         if ($search_value === null) {
2390
-            $arrayFunction = function () {
2390
+            $arrayFunction = function() {
2391 2391
                 foreach ($this->getGenerator() as $key => $value) {
2392 2392
                     yield $key;
2393 2393
                 }
2394 2394
             };
2395 2395
         } else {
2396
-            $arrayFunction = function () use ($search_value, $strict) {
2396
+            $arrayFunction = function() use ($search_value, $strict) {
2397 2397
                 foreach ($this->getGenerator() as $key => $value) {
2398 2398
                     if ($strict) {
2399 2399
                         if ($search_value === $value) {
@@ -2558,7 +2558,7 @@  discard block
 block discarded – undo
2558 2558
         $useArguments = \func_num_args() > 2;
2559 2559
 
2560 2560
         return static::create(
2561
-            function () use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
2561
+            function() use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
2562 2562
                 foreach ($this->getGenerator() as $key => $value) {
2563 2563
                     if ($useArguments) {
2564 2564
                         if ($useKeyAsSecondParameter) {
@@ -2913,7 +2913,7 @@  discard block
 block discarded – undo
2913 2913
                 )->prependToEachKey($suffix)
2914 2914
                     ->toArray();
2915 2915
             } else {
2916
-                $result[$key . $suffix] = $item;
2916
+                $result[$key.$suffix] = $item;
2917 2917
             }
2918 2918
         }
2919 2919
 
@@ -2950,7 +2950,7 @@  discard block
 block discarded – undo
2950 2950
             } elseif (\is_object($item)) {
2951 2951
                 $result[$key] = $item;
2952 2952
             } else {
2953
-                $result[$key] = $item . $suffix;
2953
+                $result[$key] = $item.$suffix;
2954 2954
             }
2955 2955
         }
2956 2956
 
@@ -3482,7 +3482,7 @@  discard block
 block discarded – undo
3482 3482
     public function replaceValues($search, $replacement = ''): self
3483 3483
     {
3484 3484
         $array = $this->each(
3485
-            static function ($value) use ($search, $replacement) {
3485
+            static function($value) use ($search, $replacement) {
3486 3486
                 return \str_replace($search, $replacement, $value);
3487 3487
             }
3488 3488
         );
@@ -3981,7 +3981,7 @@  discard block
 block discarded – undo
3981 3981
             );
3982 3982
 
3983 3983
             $results = $arrayy->each(
3984
-                function ($value) use ($sorter) {
3984
+                function($value) use ($sorter) {
3985 3985
                     if (\is_callable($sorter)) {
3986 3986
                         return $sorter($value);
3987 3987
                     }
@@ -4043,7 +4043,7 @@  discard block
 block discarded – undo
4043 4043
     public function stripEmpty(): self
4044 4044
     {
4045 4045
         return $this->filter(
4046
-            static function ($item) {
4046
+            static function($item) {
4047 4047
                 if ($item === null) {
4048 4048
                     return false;
4049 4049
                 }
@@ -4128,7 +4128,7 @@  discard block
 block discarded – undo
4128 4128
         // INFO: \array_unique() can't handle e.g. "stdClass"-values in an array
4129 4129
 
4130 4130
         $this->array = $this->reduce(
4131
-            static function ($resultArray, $value) {
4131
+            static function($resultArray, $value) {
4132 4132
                 if (!\in_array($value, $resultArray, true)) {
4133 4133
                     $resultArray[] = $value;
4134 4134
                 }
@@ -4157,7 +4157,7 @@  discard block
 block discarded – undo
4157 4157
 
4158 4158
         $this->array = \array_reduce(
4159 4159
             \array_keys($array),
4160
-            static function ($resultArray, $key) use ($array) {
4160
+            static function($resultArray, $key) use ($array) {
4161 4161
                 if (!\in_array($array[$key], $resultArray, true)) {
4162 4162
                     $resultArray[$key] = $array[$key];
4163 4163
                 }
@@ -4242,7 +4242,7 @@  discard block
 block discarded – undo
4242 4242
     public function values(): self
4243 4243
     {
4244 4244
         return static::create(
4245
-            function () {
4245
+            function() {
4246 4246
                 /** @noinspection YieldFromCanBeUsedInspection */
4247 4247
                 foreach ($this->getGenerator() as $value) {
4248 4248
                     yield $value;
@@ -4643,7 +4643,7 @@  discard block
 block discarded – undo
4643 4643
             $this->properties !== []
4644 4644
         ) {
4645 4645
             if (isset($this->properties[$key]) === false) {
4646
-                throw new \InvalidArgumentException('The key ' . $key . ' does not exists as @property in the class (' . \get_class($this) . ').');
4646
+                throw new \InvalidArgumentException('The key '.$key.' does not exists as @property in the class ('.\get_class($this).').');
4647 4647
             }
4648 4648
 
4649 4649
             $this->properties[$key]->checkType($value);
@@ -4795,7 +4795,7 @@  discard block
 block discarded – undo
4795 4795
     private function getPropertiesFromPhpDoc(): array
4796 4796
     {
4797 4797
         static $PROPERTY_CACHE = [];
4798
-        $cacheKey = 'Class::' . static::class;
4798
+        $cacheKey = 'Class::'.static::class;
4799 4799
 
4800 4800
         if (isset($PROPERTY_CACHE[$cacheKey])) {
4801 4801
             return $PROPERTY_CACHE[$cacheKey];
Please login to merge, or discard this patch.