Completed
Push — releases/v0.2.1 ( 8d5d04...e66e88 )
by Luke
03:06
created
src/CSVelte/Autoloader.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
         $paths = $this->getPaths();
63 63
         if ($rp = realpath($path)) {
64 64
             if (in_array($rp, $paths)) return true;
65
-            $this->paths []= $rp;
65
+            $this->paths [] = $rp;
66 66
             return true;
67 67
         }
68
-        $this->paths []= $path;
68
+        $this->paths [] = $path;
69 69
         return false;
70 70
     }
71 71
 
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function load($className)
115 115
     {
116
-        if(class_exists($className)) {
116
+        if (class_exists($className)) {
117 117
             return;
118 118
         }
119 119
         $fqcp = str_replace(self::NAMESPACE_SEPARATOR, DIRECTORY_SEPARATOR, $className);
120 120
         $paths = $this->getPaths();
121 121
         foreach ($paths as $path) {
122
-            $classPath = $path . DIRECTORY_SEPARATOR . $fqcp . '.php';
123
-            if(file_exists($classPath) && is_readable($classPath)) {
122
+            $classPath = $path.DIRECTORY_SEPARATOR.$fqcp.'.php';
123
+            if (file_exists($classPath) && is_readable($classPath)) {
124 124
                 require_once($classPath);
125 125
                 return;
126 126
             }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,9 @@
 block discarded – undo
61 61
     {
62 62
         $paths = $this->getPaths();
63 63
         if ($rp = realpath($path)) {
64
-            if (in_array($rp, $paths)) return true;
64
+            if (in_array($rp, $paths)) {
65
+                return true;
66
+            }
65 67
             $this->paths []= $rp;
66 68
             return true;
67 69
         }
Please login to merge, or discard this patch.
src/CSVelte/Exception/HeaderException.php 1 patch
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,6 @@
 block discarded – undo
19 19
 if (if $file->hasHeader()) {
20 20
     $header = $file->getHeader()
21 21
 }
22
-
23 22
  * you can instead simply call $header->getHeader() and handle this exception if
24 23
  * said file has no header
25 24
  *
Please login to merge, or discard this patch.
src/CSVelte/Traits/IsWritable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
      */
41 41
     public function writeLine($line, $eol = PHP_EOL)
42 42
     {
43
-        return $this->write($line . $eol);
43
+        return $this->write($line.$eol);
44 44
     }
45 45
 
46 46
     /**
Please login to merge, or discard this patch.
src/CSVelte/IO/BufferStream.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -267,16 +267,16 @@
 block discarded – undo
267 267
         return strlen($data);
268 268
     }
269 269
 
270
-     /**
271
-      * Seekability accessor.
272
-      *
273
-      * Despite the fact that any class that implements this interface must also
274
-      * define methods such as seek, that is no guarantee that an
275
-      * object will necessarily be seekable. This method should tell the user
276
-      * whether a stream is, in fact, seekable.
277
-      *
278
-      * @return boolean True if seekable, false otherwise
279
-      */
270
+        /**
271
+         * Seekability accessor.
272
+         *
273
+         * Despite the fact that any class that implements this interface must also
274
+         * define methods such as seek, that is no guarantee that an
275
+         * object will necessarily be seekable. This method should tell the user
276
+         * whether a stream is, in fact, seekable.
277
+         *
278
+         * @return boolean True if seekable, false otherwise
279
+         */
280 280
     public function isSeekable()
281 281
     {
282 282
         return $this->seekable;
Please login to merge, or discard this 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.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      * Read in the specified amount of characters from the input source
120 120
      *
121 121
      * @param integer Amount of characters to read from input source
122
-     * @return string|boolean The specified amount of characters read from input source
122
+     * @return false|string The specified amount of characters read from input source
123 123
      */
124 124
     public function read($chars)
125 125
     {
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      *
247 247
      * After the stream has been detached, the stream is in an unusable state.
248 248
      *
249
-     * @return BufferStream|null Underlying PHP stream, if any
249
+     * @return string Underlying PHP stream, if any
250 250
      */
251 251
     public function detach()
252 252
     {
Please login to merge, or discard this patch.
src/CSVelte/Collection.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     public function toArray()
195 195
     {
196 196
         $data = [];
197
-        foreach($this->data as $key => $val) {
197
+        foreach ($this->data as $key => $val) {
198 198
             $data[$key] = (is_object($val) && method_exists($val, 'toArray')) ? $val->toArray() : $val;
199 199
         }
200 200
         return $data;
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
             if ($i === $pos) return $key;
370 370
             $i++;
371 371
         }
372
-        throw new OutOfBoundsException("Collection data does not contain a key at given position: " . $pos);
372
+        throw new OutOfBoundsException("Collection data does not contain a key at given position: ".$pos);
373 373
     }
374 374
 
375 375
     /**
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
             return $this->data[$key];
555 555
         } else {
556 556
             if ($throwExc) {
557
-                throw new OutOfBoundsException("Collection data does not contain value for given key: " . $key);
557
+                throw new OutOfBoundsException("Collection data does not contain value for given key: ".$key);
558 558
             }
559 559
         }
560 560
         return $default;
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
     public function pairs($alt = false)
900 900
     {
901 901
         return new self(array_map(
902
-            function ($key, $val) use ($alt) {
902
+            function($key, $val) use ($alt) {
903 903
                 if ($alt) {
904 904
                     return [$key => $val];
905 905
                 } else {
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
         if (false !== ($condRet = $this->if2DMapInternalMethod(__METHOD__))) {
982 982
             return $condRet;
983 983
         }
984
-        $strvals = $this->map(function($val){
984
+        $strvals = $this->map(function($val) {
985 985
             return (string) $val;
986 986
         });
987 987
         $this->assertNumericValues();
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
         $this->assertIsTabular();
1096 1096
         return $this->sort(function($a, $b) use ($key, $cmp) {
1097 1097
             if (!isset($a[$key]) || !isset($b[$key])) {
1098
-                throw new RuntimeException('Cannot order collection by non-existant key: ' . $key);
1098
+                throw new RuntimeException('Cannot order collection by non-existant key: '.$key);
1099 1099
             }
1100 1100
             if (is_null($cmp)) {
1101 1101
                 return strcasecmp($a[$key], $b[$key]);
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
      */
1143 1143
     public function is2D()
1144 1144
     {
1145
-        return !$this->contains(function($val){
1145
+        return !$this->contains(function($val) {
1146 1146
             return !is_array($val);
1147 1147
         });
1148 1148
         return false;
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
 
1213 1213
     protected function assertNumericValues()
1214 1214
     {
1215
-        if ($this->contains(function($val){
1215
+        if ($this->contains(function($val) {
1216 1216
             return !is_numeric($val);
1217 1217
         })) {
1218 1218
             // can't average non-numeric data
@@ -1228,6 +1228,6 @@  discard block
 block discarded – undo
1228 1228
         if (is_null($data) || is_array($data) || $data instanceof Iterator) {
1229 1229
             return;
1230 1230
         }
1231
-        throw new InvalidArgumentException("Invalid type for collection data: " . gettype($data));
1231
+        throw new InvalidArgumentException("Invalid type for collection data: ".gettype($data));
1232 1232
     }
1233 1233
 }
Please login to merge, or discard this 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.
Doc Comments   +14 added lines, -11 removed lines patch added patch discarded remove patch
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
      *
616 616
      * @param int|mixed The offset to set
617 617
      * @param any The value to set it to
618
-     * @return boolean
618
+     * @return Collection
619 619
      */
620 620
     public function offsetSet($offset, $value)
621 621
     {
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
      *
685 685
      * @param boolean $multi Whether to count just the items in the collection or
686 686
      *     to count the items in each tabular data row.
687
-     * @return int|\CSVelte\Collection Either an integer count or a collection of counts
687
+     * @return string Either an integer count or a collection of counts
688 688
      */
689 689
     public function count($multi = false)
690 690
     {
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
      * Filter out unwanted items using a callback function.
772 772
      *
773 773
      * @param Callable $callback
774
-     * @return CSVelte\Collection A new collection with filtered items removed
774
+     * @return Collection A new collection with filtered items removed
775 775
      */
776 776
     public function filter(Callable $callback)
777 777
     {
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
      * Returns an array where the key is a value in the collection and the value
824 824
      * is the number of times that value appears in the collection.
825 825
      *
826
-     * @return CSVelte\Collection A collection of value frequencies (see description)
826
+     * @return Collection A collection of value frequencies (see description)
827 827
      */
828 828
     public function frequency()
829 829
     {
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
      * Returns a collection with duplicate values removed. If two-dimensional,
848 848
      * then each array within the collection will have its duplicates removed.
849 849
      *
850
-     * @return CSVelte\Collection A new collection with duplicate values removed.
850
+     * @return Collection A new collection with duplicate values removed.
851 851
      */
852 852
     public function unique()
853 853
     {
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
      * Returns a collection of arrays where the key is the duplicate value
864 864
      * and the value is an array of keys from the original collection.
865 865
      *
866
-     * @return CSVelte\Collection A new collection with duplicate values.
866
+     * @return Collection A new collection with duplicate values.
867 867
      */
868 868
     public function duplicates()
869 869
     {
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
      *
882 882
      * Get a new collection where the keys and values have been swapped.
883 883
      *
884
-     * @return CSVelte\Collection A new collection where keys/values have been swapped
884
+     * @return Collection A new collection where keys/values have been swapped
885 885
      */
886 886
     public function flip()
887 887
     {
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
      * first is the default.
896 896
      *
897 897
      * @param boolean Whether you want pairs in [k => v] rather than [k, v] format
898
-     * @return CSVelte\Collection A collection of key/value pairs
898
+     * @return Collection A collection of key/value pairs
899 899
      */
900 900
     public function pairs($alt = false)
901 901
     {
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
      *
1060 1060
      * @param Callable $callback The sorting function you want to use
1061 1061
      * @param boolean $preserve_keys Whether you want to preserve keys
1062
-     * @return CSVelte\Collection A new collection sorted by $callback
1062
+     * @return Collection A new collection sorted by $callback
1063 1063
      */
1064 1064
     public function sort(Callable $callback = null, $preserve_keys = true)
1065 1065
     {
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
      * @param string $key The key you want to order by
1090 1090
      * @param Callable $cmp The sorting comparison algorithm to use
1091 1091
      * @param boolean $preserve_keys Whether keys should be preserved
1092
-     * @return CSVelte\Collection A new collection sorted by $cmp and $key
1092
+     * @return Collection A new collection sorted by $cmp and $key
1093 1093
      */
1094 1094
     public function orderBy($key, Callable $cmp = null, $preserve_keys = true)
1095 1095
     {
@@ -1113,13 +1113,16 @@  discard block
 block discarded – undo
1113 1113
      * trying to write a particular sorting algurithm that sorts forwards and back.
1114 1114
      *
1115 1115
      * @param boolean $preserve_keys Whether keys should be preserved
1116
-     * @return CSVelte\Collection A new collection in reverse order
1116
+     * @return Collection A new collection in reverse order
1117 1117
      */
1118 1118
     public function reverse($preserve_keys = true)
1119 1119
     {
1120 1120
         return new self(array_reverse($this->data, $preserve_keys));
1121 1121
     }
1122 1122
 
1123
+    /**
1124
+     * @param string $method
1125
+     */
1123 1126
     protected function if2DMapInternalMethod($method)
1124 1127
     {
1125 1128
         if ($this->is2D()) {
Please login to merge, or discard this patch.
src/CSVelte/functions.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,9 @@
 block discarded – undo
91 91
 {
92 92
     $res = (new Resource($uri, $mode))
93 93
         ->setContextResource($context);
94
-    if (!$lazy) $res->connect();
94
+    if (!$lazy) {
95
+        $res->connect();
96
+    }
95 97
     return $res;
96 98
 }
97 99
 
Please login to merge, or discard this patch.
src/CSVelte/Contract/Streamable.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -267,16 +267,16 @@
 block discarded – undo
267 267
         return strlen($data);
268 268
     }
269 269
 
270
-     /**
271
-      * Seekability accessor.
272
-      *
273
-      * Despite the fact that any class that implements this interface must also
274
-      * define methods such as seek, that is no guarantee that an
275
-      * object will necessarily be seekable. This method should tell the user
276
-      * whether a stream is, in fact, seekable.
277
-      *
278
-      * @return boolean True if seekable, false otherwise
279
-      */
270
+        /**
271
+         * Seekability accessor.
272
+         *
273
+         * Despite the fact that any class that implements this interface must also
274
+         * define methods such as seek, that is no guarantee that an
275
+         * object will necessarily be seekable. This method should tell the user
276
+         * whether a stream is, in fact, seekable.
277
+         *
278
+         * @return boolean True if seekable, false otherwise
279
+         */
280 280
     public function isSeekable()
281 281
     {
282 282
         return $this->seekable;
Please login to merge, or discard this patch.
src/CSVelte/IO/IteratorStream.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -267,16 +267,16 @@
 block discarded – undo
267 267
         return strlen($data);
268 268
     }
269 269
 
270
-     /**
271
-      * Seekability accessor.
272
-      *
273
-      * Despite the fact that any class that implements this interface must also
274
-      * define methods such as seek, that is no guarantee that an
275
-      * object will necessarily be seekable. This method should tell the user
276
-      * whether a stream is, in fact, seekable.
277
-      *
278
-      * @return boolean True if seekable, false otherwise
279
-      */
270
+        /**
271
+         * Seekability accessor.
272
+         *
273
+         * Despite the fact that any class that implements this interface must also
274
+         * define methods such as seek, that is no guarantee that an
275
+         * object will necessarily be seekable. This method should tell the user
276
+         * whether a stream is, in fact, seekable.
277
+         *
278
+         * @return boolean True if seekable, false otherwise
279
+         */
280 280
     public function isSeekable()
281 281
     {
282 282
         return $this->seekable;
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
     /**
260 260
      * Closes the stream and any underlying resources.
261 261
      *
262
-     * @return void
262
+     * @return boolean
263 263
      */
264 264
     public function close()
265 265
     {
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      *
278 278
      * After the stream has been detached, the stream is in an unusable state.
279 279
      *
280
-     * @return array|Resource Underlying PHP stream, if any
280
+     * @return string Underlying PHP stream, if any
281 281
      * @todo I'm not sure what detach is for so I don't know whether what I'm
282 282
      *     doing here is right. The reason I have the method at all is because
283 283
      *     psr7 StreamInterface has one.f
Please login to merge, or discard this patch.