Passed
Push — master ( 107afa...98b7dd )
by Jean
02:12
created
src/Exceptions/UsageException.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,21 +18,21 @@
 block discarded – undo
18 18
     {
19 19
         parent::__construct(...func_get_args());
20 20
 
21
-        $this->rewindStackWhile( function($backtrace, $level) {
21
+        $this->rewindStackWhile(function($backtrace, $level) {
22 22
             // Finds the closest caller
23
-            return  isset($backtrace[ $level ]['class'])
24
-                &&  $backtrace[ $level ]['class'] == __CLASS__;
25
-        }, 0 );
23
+            return  isset($backtrace[$level]['class'])
24
+                &&  $backtrace[$level]['class'] == __CLASS__;
25
+        }, 0);
26 26
     }
27 27
 
28 28
     /**
29 29
      */
30
-    protected function rewindStackWhile(callable $scope_checker, $stack_max_depth=20)
30
+    protected function rewindStackWhile(callable $scope_checker, $stack_max_depth = 20)
31 31
     {
32
-        $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, $stack_max_depth);
32
+        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $stack_max_depth);
33 33
         $i         = 1;
34 34
         $caller    = $backtrace[$i];
35
-        while ( $scope_checker( $backtrace, $i ) ) {
35
+        while ($scope_checker($backtrace, $i)) {
36 36
             $i++;
37 37
             $caller = $backtrace[$i];
38 38
             // TODO remove the prevuce levels of the stack?
Please login to merge, or discard this patch.
src/Arrays/Arrays.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
     public static function mergeRecursiveCustom(
136 136
         $existing_row,
137 137
         $conflict_row,
138
-        callable $merge_resolver=null,
139
-        $max_depth=null
140
-    ){
138
+        callable $merge_resolver = null,
139
+        $max_depth = null
140
+    ) {
141 141
         static::mustBeCountable($existing_row);
142 142
         static::mustBeCountable($conflict_row);
143 143
 
144 144
         foreach ($conflict_row as $column => $conflict_value) {
145 145
 
146 146
             // not existing in first array
147
-            if (!isset($existing_row[$column])) {
147
+            if ( ! isset($existing_row[$column])) {
148 148
                 $existing_row[$column] = $conflict_value;
149 149
                 continue;
150 150
             }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             }
178 178
             else {
179 179
                 // same resolution as array_merge_recursive
180
-                if (!is_array($existing_value)) {
180
+                if ( ! is_array($existing_value)) {
181 181
                     $existing_row[$column] = [$existing_value];
182 182
                 }
183 183
 
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
     public static function mergePreservingDistincts(
201 201
         $existing_row,
202 202
         $conflict_row
203
-    ){
203
+    ) {
204 204
         static::mustBeCountable($existing_row);
205 205
         static::mustBeCountable($conflict_row);
206 206
 
207 207
         $merge = static::mergeRecursiveCustom(
208 208
             $existing_row,
209 209
             $conflict_row,
210
-            function ($existing_value, $conflict_value, $column) {
210
+            function($existing_value, $conflict_value, $column) {
211 211
 
212 212
                 if ( ! $existing_value instanceof MergeBucket) {
213 213
                     $existing_value = MergeBucket::from()->push($existing_value);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      * @param  array|Countable   $row
237 237
      * @param  array             $options : 'excluded_columns'
238 238
      */
239
-    public static function cleanMergeDuplicates($row, array $options=[])
239
+    public static function cleanMergeDuplicates($row, array $options = [])
240 240
     {
241 241
         static::mustBeCountable($row);
242 242
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      * @see mergePreservingDistincts()
270 270
      * @see cleanMergeDuplicates()
271 271
      */
272
-    public static function cleanMergeBuckets($row, array $options=[])
272
+    public static function cleanMergeBuckets($row, array $options = [])
273 273
     {
274 274
         static::mustBeCountable($row);
275 275
 
@@ -310,13 +310,13 @@  discard block
 block discarded – undo
310 310
                 $id = serialize($value);
311 311
             }
312 312
 
313
-            if (isset($ids[ $id ])) {
314
-                unset($array[ $key ]);
315
-                $ids[ $id ][] = $key;
313
+            if (isset($ids[$id])) {
314
+                unset($array[$key]);
315
+                $ids[$id][] = $key;
316 316
                 continue;
317 317
             }
318 318
 
319
-            $ids[ $id ] = [$key];
319
+            $ids[$id] = [$key];
320 320
         }
321 321
 
322 322
         return $array;
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         }
337 337
         else {
338 338
             throw new \InvalidArgumentException(
339
-                "keyExists() method missing on :\n". var_export($array, true)
339
+                "keyExists() method missing on :\n".var_export($array, true)
340 340
             );
341 341
         }
342 342
 
@@ -412,16 +412,16 @@  discard block
 block discarded – undo
412 412
             throw new \InvalidArgumentException(
413 413
                 "Different number of "
414 414
                 ." values and weights for weight mean calculation: \n"
415
-                .var_export($values,  true)."\n\n"
415
+                .var_export($values, true)."\n\n"
416 416
                 .var_export($weights, true)
417 417
             );
418 418
         }
419 419
 
420
-        if (!$values)
420
+        if ( ! $values)
421 421
             return null;
422 422
 
423
-        $weights_sum  = array_sum($weights);
424
-        if (!$weights_sum)
423
+        $weights_sum = array_sum($weights);
424
+        if ( ! $weights_sum)
425 425
             return 0;
426 426
 
427 427
         $weighted_sum = 0;
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
         );
471 471
 
472 472
         // The true location of the throw is still available through the backtrace
473
-        $trace_location  = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
474
-        $reflectionClass = new \ReflectionClass( get_class($exception) );
473
+        $trace_location  = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
474
+        $reflectionClass = new \ReflectionClass(get_class($exception));
475 475
 
476 476
         // file
477 477
         if (isset($trace_location['file'])) {
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
         );
509 509
 
510 510
         // The true location of the throw is still available through the backtrace
511
-        $trace_location  = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
512
-        $reflectionClass = new \ReflectionClass( get_class($exception) );
511
+        $trace_location  = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
512
+        $reflectionClass = new \ReflectionClass(get_class($exception));
513 513
 
514 514
         // file
515 515
         if (isset($trace_location['file'])) {
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
      *
550 550
      * @return string       The unique identifier of the group
551 551
      */
552
-    public static function generateGroupId($row, array $groups_definitions, array $options=[])
552
+    public static function generateGroupId($row, array $groups_definitions, array $options = [])
553 553
     {
554 554
         Arrays::mustBeCountable($row);
555 555
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
                              : ':'
559 559
                              ;
560 560
 
561
-        $groups_separator    = ! empty($options['groups_separator'])
561
+        $groups_separator = ! empty($options['groups_separator'])
562 562
                              ? $options['groups_separator']
563 563
                              : '-'
564 564
                              ;
@@ -573,11 +573,11 @@  discard block
 block discarded – undo
573 573
 
574 574
             if (is_string($group_definition_value) && array_key_exists($group_definition_value, $row)) {
575 575
                 $part_name         .= $group_definition_value;
576
-                $group_result_value = $row[ $group_definition_value ];
576
+                $group_result_value = $row[$group_definition_value];
577 577
             }
578 578
             elseif (is_int($group_definition_value)) {
579
-                $part_name         .= $group_definition_value ? : '0';
580
-                $group_result_value = $row[ $group_definition_value ];
579
+                $part_name         .= $group_definition_value ?: '0';
580
+                $group_result_value = $row[$group_definition_value];
581 581
             }
582 582
             /* TODO check this is not just dead code * /
583 583
             elseif (is_callable($group_definition_value)) {
@@ -604,12 +604,12 @@  discard block
 block discarded – undo
604 604
                 throw new UsageException(
605 605
                     'Bad value provided for groupBy id generation: '
606 606
                     .var_export($group_definition_value, true)
607
-                    ."\n" . var_export($row, true)
607
+                    ."\n".var_export($row, true)
608 608
                 );
609 609
             }
610 610
 
611
-            if (!is_null($part_name))
612
-                $group_parts[ $part_name ] = $group_result_value;
611
+            if ( ! is_null($part_name))
612
+                $group_parts[$part_name] = $group_result_value;
613 613
         }
614 614
 
615 615
         // sort the groups by names (without it the same group could have multiple ids)
@@ -621,13 +621,13 @@  discard block
 block discarded – undo
621 621
             if (is_object($group_value)) {
622 622
                 $group_value = get_class($group_value)
623 623
                              . '_'
624
-                             . hash( 'crc32b', var_export($group_value, true) );
624
+                             . hash('crc32b', var_export($group_value, true));
625 625
             }
626 626
             elseif (is_array($group_value)) {
627
-                $group_value = 'array_' . hash( 'crc32b', var_export($group_value, true) );
627
+                $group_value = 'array_'.hash('crc32b', var_export($group_value, true));
628 628
             }
629 629
 
630
-            $out[] = $group_name . $key_value_separator . $group_value;
630
+            $out[] = $group_name.$key_value_separator.$group_value;
631 631
         }
632 632
 
633 633
         return implode($groups_separator, $out);
Please login to merge, or discard this patch.