Completed
Push — master ( 5c1aea...9ef1c4 )
by Luke
03:03
created
src/CSVelte/Taster.php 1 patch
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -169,7 +169,9 @@  discard block
 block discarded – undo
169 169
         try {
170 170
             list($quoteChar, $delimiter) = $this->lickQuoteAndDelim();
171 171
         } catch (TasterException $e) {
172
-            if ($e->getCode() !== TasterException::ERR_QUOTE_AND_DELIM) throw $e;
172
+            if ($e->getCode() !== TasterException::ERR_QUOTE_AND_DELIM) {
173
+                throw $e;
174
+            }
173 175
             $quoteChar = '"';
174 176
             $delimiter = $this->lickDelimiter($lineTerminator);
175 177
         }
@@ -265,7 +267,9 @@  discard block
 block discarded – undo
265 267
         foreach ($patterns as $pattern) {
266 268
             // @todo I had to add the error suppression char here because it was
267 269
             //     causing undefined offset errors with certain data sets. strange...
268
-            if (@preg_match_all($pattern, $this->sample, $matches) && $matches) break;
270
+            if (@preg_match_all($pattern, $this->sample, $matches) && $matches) {
271
+                break;
272
+            }
269 273
         }
270 274
         if ($matches) {
271 275
             try {
@@ -388,7 +392,9 @@  discard block
 block discarded – undo
388 392
                  // if somehow we STILL can't come to a consensus, then fall back to a
389 393
                  // "preferred delimiters" list...
390 394
                  foreach ($this->delims as $key => $val) {
391
-                    if ($delim = array_search($val, $decision)) return $delim;
395
+                    if ($delim = array_search($val, $decision)) {
396
+                        return $delim;
397
+                    }
392 398
                  }
393 399
              }
394 400
         }
@@ -431,7 +437,9 @@  discard block
 block discarded – undo
431 437
             return $delims[collect($delims)->map(function($delim) use (&$distrib, $lines) {
432 438
                 $linedist = collect();
433 439
                 $lines->walk(function($line, $line_no) use (&$linedist, $delim) {
434
-                    if (!strlen($line)) return;
440
+                    if (!strlen($line)) {
441
+                        return;
442
+                    }
435 443
                     $sectstot = 10;
436 444
                     $sectlen = (int) (strlen($line) / $sectstot);
437 445
                     $sections = collect(str_split($line, $sectlen))
@@ -519,8 +527,12 @@  discard block
 block discarded – undo
519 527
         $quoting_styles = $quoting_styles->filter(function($val) { return (bool) $val; });
520 528
         // if quoting_styles still has QUOTE_ALL or QUOTE_NONE, then return
521 529
         // whichever of them it is, we don't need to do anything else
522
-        if ($quoting_styles->has(Flavor::QUOTE_ALL)) return Flavor::QUOTE_ALL;
523
-        if ($quoting_styles->has(Flavor::QUOTE_NONE)) return Flavor::QUOTE_NONE;
530
+        if ($quoting_styles->has(Flavor::QUOTE_ALL)) {
531
+            return Flavor::QUOTE_ALL;
532
+        }
533
+        if ($quoting_styles->has(Flavor::QUOTE_NONE)) {
534
+            return Flavor::QUOTE_NONE;
535
+        }
524 536
         if (count($types) == 1) {
525 537
             $style = $types->getValueAtPosition(0);
526 538
             if ($quoting_styles->has($style)) {
@@ -537,7 +549,9 @@  discard block
 block discarded – undo
537 549
                 if ($most = $counts->max()) {
538 550
                     $least = $counts->min();
539 551
                     $err_margin = $least / $most;
540
-                    if ($err_margin < 1) return Flavor::QUOTE_NONNUMERIC;
552
+                    if ($err_margin < 1) {
553
+                        return Flavor::QUOTE_NONNUMERIC;
554
+                    }
541 555
                 }
542 556
             }
543 557
         }
@@ -712,7 +726,9 @@  discard block
 block discarded – undo
712 726
                 $field = str_replace(self::PLACEHOLDER_DELIM, $delim, $field);
713 727
                 // @todo Need a Collection::setTableField($x, $y) method
714 728
                 //       See notes in green binder about refactoring Collection
715
-                if (!$types->has($line_no)) $types->set($line_no, collect());
729
+                if (!$types->has($line_no)) {
730
+                    $types->set($line_no, collect());
731
+                }
716 732
                 $types->get($line_no)->set($colpos, [
717 733
                     'type' => $this->lickType($this->unQuote($field)),
718 734
                     'length' => strlen($field)
@@ -735,12 +751,18 @@  discard block
 block discarded – undo
735 751
                     extract($possibleHeader->get($col_no, null, true), EXTR_PREFIX_ALL, "header");
736 752
                     if ($header_type == self::TYPE_STRING) {
737 753
                         // use length
738
-                        if ($length != $header_length) $hasHeader++;
739
-                        else $hasHeader--;
754
+                        if ($length != $header_length) {
755
+                            $hasHeader++;
756
+                        } else {
757
+                            $hasHeader--;
758
+                        }
740 759
                     } else {
741 760
                         // use data type
742
-                        if ($type != $header_type) $hasHeader++;
743
-                        else $hasHeader--;
761
+                        if ($type != $header_type) {
762
+                            $hasHeader++;
763
+                        } else {
764
+                            $hasHeader--;
765
+                        }
744 766
                     }
745 767
                 } catch (OutOfBoundsException $e) {
746 768
                     // failure...
Please login to merge, or discard this patch.
src/CSVelte/IO/Resource.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -254,7 +254,9 @@  discard block
 block discarded – undo
254 254
                 $this->getContext()
255 255
             );
256 256
             restore_error_handler();
257
-            if ($e) throw $e;
257
+            if ($e) {
258
+                throw $e;
259
+            }
258 260
         }
259 261
         return $this->isConnected();
260 262
     }
@@ -328,7 +330,9 @@  discard block
 block discarded – undo
328 330
     public function setMode($mode = null)
329 331
     {
330 332
         $this->assertNotConnected(__METHOD__);
331
-        if (is_null($mode)) $mode = "r+b";
333
+        if (is_null($mode)) {
334
+            $mode = "r+b";
335
+        }
332 336
 
333 337
         $mode = substr($mode, 0, 3);
334 338
         $rest = substr($mode, 1);
@@ -436,7 +440,9 @@  discard block
 block discarded – undo
436 440
      */
437 441
     protected function setLazy($lazy)
438 442
     {
439
-        if (is_null($lazy)) $lazy = true;
443
+        if (is_null($lazy)) {
444
+            $lazy = true;
445
+        }
440 446
         $this->lazy = (boolean) $lazy;
441 447
         return $this;
442 448
     }
Please login to merge, or discard this patch.
src/CSVelte/IO/Stream.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -136,7 +136,9 @@  discard block
 block discarded – undo
136 136
     {
137 137
         $resource = (new Resource($uri, $mode))
138 138
             ->setContextResource($context);
139
-        if (!$lazy) $resource->connect();
139
+        if (!$lazy) {
140
+            $resource->connect();
141
+        }
140 142
         return new self($resource);
141 143
     }
142 144
 
@@ -169,7 +171,9 @@  discard block
 block discarded – undo
169 171
             }
170 172
             // if a certain value was requested, return it
171 173
             // otherwise, return entire array
172
-            if (is_null($key)) return $this->meta;
174
+            if (is_null($key)) {
175
+                return $this->meta;
176
+            }
173 177
             return (array_key_exists($key, $this->meta)) ? $this->meta[$key] : null;
174 178
         }
175 179
     }
@@ -315,7 +319,9 @@  discard block
 block discarded – undo
315 319
     public function read($length)
316 320
     {
317 321
         $this->assertIsReadable();
318
-        if ($this->eof()) return false;
322
+        if ($this->eof()) {
323
+            return false;
324
+        }
319 325
         return fread($this->resource->getHandle(), $length);
320 326
     }
321 327
 
Please login to merge, or discard this patch.
src/CSVelte/Collection.php 1 patch
Braces   +30 added lines, -11 removed lines patch added patch discarded remove patch
@@ -153,8 +153,9 @@  discard block
 block discarded – undo
153 153
             }
154 154
         } else {
155 155
             if (is_null($key)) {
156
-                if (is_array($val)) return $this->merge($val);
157
-                else {
156
+                if (is_array($val)) {
157
+                    return $this->merge($val);
158
+                } else {
158 159
                     if (is_callable($val)) {
159 160
                         return $this->map($val);
160 161
                     } /*else {
@@ -248,7 +249,9 @@  discard block
 block discarded – undo
248 249
     {
249 250
         if (is_callable($callback = $val)) {
250 251
             foreach ($this->data as $key => $val) {
251
-                if ($callback($val, $key)) return true;
252
+                if ($callback($val, $key)) {
253
+                    return true;
254
+                }
252 255
             }
253 256
         } elseif (in_array($val, $this->data)) {
254 257
             return (is_null($key) || (isset($this->data[$key]) && $this->data[$key] == $val));
@@ -366,7 +369,9 @@  discard block
 block discarded – undo
366 369
     {
367 370
         $i = 0;
368 371
         foreach ($this->data as $key => $val) {
369
-            if ($i === $pos) return $key;
372
+            if ($i === $pos) {
373
+                return $key;
374
+            }
370 375
             $i++;
371 376
         }
372 377
         throw new OutOfBoundsException("Collection data does not contain a key at given position: " . $pos);
@@ -744,7 +749,9 @@  discard block
 block discarded – undo
744 749
     {
745 750
         foreach ($this->data as $key => $val) {
746 751
             if (!$ret = $callback($val, $key)) {
747
-                if ($ret === false) break;
752
+                if ($ret === false) {
753
+                    break;
754
+                }
748 755
             }
749 756
         }
750 757
         return $this;
@@ -776,7 +783,9 @@  discard block
 block discarded – undo
776 783
     {
777 784
         $keys = [];
778 785
         foreach ($this->data as $key => $val) {
779
-            if (false === $callback($val, $key)) $keys[$key] = true;
786
+            if (false === $callback($val, $key)) {
787
+                $keys[$key] = true;
788
+            }
780 789
         }
781 790
         return new self(array_diff_key($this->data, $keys));
782 791
     }
@@ -793,7 +802,9 @@  discard block
 block discarded – undo
793 802
     public function first(Callable $callback)
794 803
     {
795 804
         foreach ($this->data as $key => $val) {
796
-            if ($callback($val, $key)) return $val;
805
+            if ($callback($val, $key)) {
806
+                return $val;
807
+            }
797 808
         }
798 809
         return null;
799 810
     }
@@ -811,7 +822,9 @@  discard block
 block discarded – undo
811 822
     {
812 823
         $elem = null;
813 824
         foreach ($this->data as $key => $val) {
814
-            if ($callback($val, $key)) $elem = $val;
825
+            if ($callback($val, $key)) {
826
+                $elem = $val;
827
+            }
815 828
         }
816 829
         return $elem;
817 830
     }
@@ -1062,7 +1075,9 @@  discard block
 block discarded – undo
1062 1075
      */
1063 1076
     public function sort(Callable $callback = null, $preserve_keys = true)
1064 1077
     {
1065
-        if (is_null($callback)) $callback = 'strcasecmp';
1078
+        if (is_null($callback)) {
1079
+            $callback = 'strcasecmp';
1080
+        }
1066 1081
         if (!is_callable($callback)) {
1067 1082
             throw new InvalidArgumentException(sprintf(
1068 1083
                 'Invalid argument supplied for %s. Expected %s, got: "%s".',
@@ -1172,7 +1187,9 @@  discard block
 block discarded – undo
1172 1187
 
1173 1188
             // if the list of array keys is shorter than the total amount of items in
1174 1189
             // the collection, than this is not tabular data
1175
-            if (count($test) != count($this)) return false;
1190
+            if (count($test) != count($this)) {
1191
+                return false;
1192
+            }
1176 1193
 
1177 1194
             // loop through the array of each item's array keys that we just created
1178 1195
             // and compare it to the FIRST item. If any array contains different keys
@@ -1180,7 +1197,9 @@  discard block
 block discarded – undo
1180 1197
             $first = array_shift($test);
1181 1198
             foreach ($test as $key => $keys) {
1182 1199
                 $diff = array_diff($first, $keys);
1183
-                if (!empty($diff)) return false;
1200
+                if (!empty($diff)) {
1201
+                    return false;
1202
+                }
1184 1203
             }
1185 1204
             return true;
1186 1205
         }
Please login to merge, or discard this patch.
src/CSVelte/IO/BufferStream.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,9 @@
 block discarded – undo
138 138
     public function readChunk($start = null, $length = null)
139 139
     {
140 140
         //dd($this->buffer, false);
141
-        if ($this->buffer === false) return false;
141
+        if ($this->buffer === false) {
142
+            return false;
143
+        }
142 144
         $top = substr($this->buffer, 0, $start);
143 145
         $data = substr($this->buffer, $start, $length);
144 146
         $bottom = substr($this->buffer, $start + $length);
Please login to merge, or discard this patch.
src/CSVelte/Table/AbstractRow.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -152,7 +152,9 @@
 block discarded – undo
152 152
     public function next()
153 153
     {
154 154
         $this->position++;
155
-        if ($this->valid()) return $this->current();
155
+        if ($this->valid()) {
156
+            return $this->current();
157
+        }
156 158
     }
157 159
 
158 160
     /**
Please login to merge, or discard this patch.