Completed
Push — master ( 748f90...5c1aea )
by Luke
08:07
created
src/CSVelte/Reader/FilteredIterator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
 
74 74
     public function toArray()
75 75
     {
76
-        return array_map(function($row){
76
+        return array_map(function($row) {
77 77
             return $row->toArray();
78 78
         }, iterator_to_array($this));
79 79
     }
Please login to merge, or discard this patch.
src/CSVelte/Flavor.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     protected function assertValidAttribute($attr)
193 193
     {
194 194
         if (!property_exists(self::class, $attr))
195
-            throw new InvalidArgumentException("Unknown attribute: " . $attr);
195
+            throw new InvalidArgumentException("Unknown attribute: ".$attr);
196 196
     }
197 197
 
198 198
     /**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public function __set($attr, $val)
243 243
     {
244
-        throw new ImmutableException("Cannot change attributes on an immutable object: " . self::class . "::\$" . $attr);
244
+        throw new ImmutableException("Cannot change attributes on an immutable object: ".self::class."::\$".$attr);
245 245
     }
246 246
 
247 247
     public function toArray()
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -191,8 +191,9 @@
 block discarded – undo
191 191
      */
192 192
     protected function assertValidAttribute($attr)
193 193
     {
194
-        if (!property_exists(self::class, $attr))
195
-            throw new InvalidArgumentException("Unknown attribute: " . $attr);
194
+        if (!property_exists(self::class, $attr)) {
195
+                    throw new InvalidArgumentException("Unknown attribute: " . $attr);
196
+        }
196 197
     }
197 198
 
198 199
     /**
Please login to merge, or discard this patch.
src/CSVelte/Table/AbstractRow.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             } elseif ($fields instanceof Iterator) {
68 68
                 $fields = iterator_to_array($fields);
69 69
             } else {
70
-                throw new InvalidArgumentException(__CLASS__ . " requires an array, got: " . gettype($fields));
70
+                throw new InvalidArgumentException(__CLASS__." requires an array, got: ".gettype($fields));
71 71
             }
72 72
         }
73 73
         $this->fields = array_values($fields);
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     protected function assertOffsetExists($offset)
250 250
     {
251 251
         if (!$this->offsetExists($offset)) {
252
-            throw new OutOfBoundsException("Undefined offset: " . $offset);
252
+            throw new OutOfBoundsException("Undefined offset: ".$offset);
253 253
         }
254 254
     }
255 255
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -151,7 +151,9 @@  discard block
 block discarded – undo
151 151
     public function next()
152 152
     {
153 153
         $this->position++;
154
-        if ($this->valid()) return $this->current();
154
+        if ($this->valid()) {
155
+            return $this->current();
156
+        }
155 157
     }
156 158
 
157 159
     /**
@@ -163,7 +165,9 @@  discard block
 block discarded – undo
163 165
     public function rewind()
164 166
     {
165 167
         $this->position = 0;
166
-        if ($this->valid()) return $this->current();
168
+        if ($this->valid()) {
169
+            return $this->current();
170
+        }
167 171
     }
168 172
 
169 173
     /**
Please login to merge, or discard this patch.
src/CSVelte/Traits/IsWritable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 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
     /**
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     protected function assertIsWritable()
53 53
     {
54 54
         if (!$this->isWritable()) {
55
-            throw new IOException("Stream not writable: " . $this->getName(), IOException::ERR_NOT_WRITABLE);
55
+            throw new IOException("Stream not writable: ".$this->getName(), IOException::ERR_NOT_WRITABLE);
56 56
         }
57 57
     }
58 58
 
Please login to merge, or discard this patch.
src/CSVelte/Traits/IsReadable.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
     protected function assertIsReadable()
76 76
     {
77 77
         if (!$this->isReadable()) {
78
-            throw new IOException("Stream not readable: " . $this->getName(), IOException::ERR_NOT_READABLE);
78
+            throw new IOException("Stream not readable: ".$this->getName(), IOException::ERR_NOT_READABLE);
79 79
         }
80 80
     }
81 81
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@
 block discarded – undo
45 45
     {
46 46
         $size = 0;
47 47
         $buffer = false;
48
-        if (!is_array($eol)) $eol = array($eol);
48
+        if (!is_array($eol)) {
49
+            $eol = array($eol);
50
+        }
49 51
         while (!$this->eof()) {
50 52
             // Using a loose equality here to match on '' and false.
51 53
             if (null == ($byte = $this->read(1))) {
Please login to merge, or discard this patch.
src/CSVelte/Traits/IsSeekable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
     protected function assertIsSeekable()
56 56
     {
57 57
         if (!$this->isSeekable()) {
58
-            throw new IOException("Stream not seekable: " . $this->getName(), IOException::ERR_NOT_SEEKABLE);
58
+            throw new IOException("Stream not seekable: ".$this->getName(), IOException::ERR_NOT_SEEKABLE);
59 59
         }
60 60
     }
61 61
 
Please login to merge, or discard this patch.
src/CSVelte/Utils.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         } else {
40 40
             if ($throwException) {
41 41
                 // @todo is this the correct exception to throw?
42
-                throw new \OutOfBoundsException('Unknown array index: ' . $key);
42
+                throw new \OutOfBoundsException('Unknown array index: '.$key);
43 43
             }
44 44
         }
45 45
         return $default;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
     public static function average($arr)
58 58
     {
59
-        if (!is_array($arr)) throw new \InvalidArgumentException('"average" function expected array, got ' . gettype($arr));
59
+        if (!is_array($arr)) throw new \InvalidArgumentException('"average" function expected array, got '.gettype($arr));
60 60
         return array_sum($arr) / count($arr);
61 61
     }
62 62
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
     public static function mode($arr)
73 73
     {
74
-        if (!is_array($arr)) throw new \InvalidArgumentException('"mode" function expected array, got ' . gettype($arr));
74
+        if (!is_array($arr)) throw new \InvalidArgumentException('"mode" function expected array, got '.gettype($arr));
75 75
         $vals = array();
76 76
         foreach ($arr as $key => $val) {
77 77
             $vals[$val] = self::array_get($vals, $val, 0) + 1;
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,7 +56,9 @@  discard block
 block discarded – undo
56 56
 
57 57
     public static function average($arr)
58 58
     {
59
-        if (!is_array($arr)) throw new \InvalidArgumentException('"average" function expected array, got ' . gettype($arr));
59
+        if (!is_array($arr)) {
60
+            throw new \InvalidArgumentException('"average" function expected array, got ' . gettype($arr));
61
+        }
60 62
         return array_sum($arr) / count($arr);
61 63
     }
62 64
 
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 
72 74
     public static function mode($arr)
73 75
     {
74
-        if (!is_array($arr)) throw new \InvalidArgumentException('"mode" function expected array, got ' . gettype($arr));
76
+        if (!is_array($arr)) {
77
+            throw new \InvalidArgumentException('"mode" function expected array, got ' . gettype($arr));
78
+        }
75 79
         $vals = array();
76 80
         foreach ($arr as $key => $val) {
77 81
             $vals[$val] = self::array_get($vals, $val, 0) + 1;
Please login to merge, or discard this patch.
src/CSVelte/Reader.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
             do {
186 186
                 if (!isset($lines)) $lines = array();
187 187
                 if (false === ($line = $this->source->readLine($eol))) {
188
-                    throw new EndOfFileException("End of file reached: " . $this->source->getName());
188
+                    throw new EndOfFileException("End of file reached: ".$this->source->getName());
189 189
                 }
190 190
                 array_push($lines, rtrim($line, $eol));
191 191
             } while ($this->inQuotedString(end($lines), $f->quoteChar, $f->escapeChar));
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
      */
280 280
     protected function replaceQuotedSpecialChars($data, $delim, $quo, $eol)
281 281
     {
282
-        return preg_replace_callback('/(['. preg_quote($quo, '/') . '])(.*)\1/imsU', function($matches) use ($delim, $eol) {
282
+        return preg_replace_callback('/(['.preg_quote($quo, '/').'])(.*)\1/imsU', function($matches) use ($delim, $eol) {
283 283
             $ret = str_replace($eol, self::PLACEHOLDER_NEWLINE, $matches[0]);
284 284
             $ret = str_replace($delim, self::PLACEHOLDER_DELIM, $ret);
285 285
             return $ret;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      */
332 332
     protected function unEscape($str, $esc, $quo)
333 333
     {
334
-        return str_replace($esc . $quo, $quo, $str);
334
+        return str_replace($esc.$quo, $quo, $str);
335 335
     }
336 336
 
337 337
     /**
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
      */
473 473
     public function toArray()
474 474
     {
475
-        return array_map(function($row){
475
+        return array_map(function($row) {
476 476
             return $row->toArray();
477 477
         }, iterator_to_array($this));
478 478
     }
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -104,7 +104,9 @@  discard block
 block discarded – undo
104 104
      */
105 105
     protected function setFlavor($flavor = null)
106 106
     {
107
-        if (is_array($flavor)) $flavor = new Flavor($flavor);
107
+        if (is_array($flavor)) {
108
+            $flavor = new Flavor($flavor);
109
+        }
108 110
         $taster = new Taster($this->source);
109 111
         // @todo put this inside a try/catch
110 112
         if (is_null($flavor)) {
@@ -159,7 +161,9 @@  discard block
 block discarded – undo
159 161
                     $this->header = new HeaderRow($parsed);
160 162
                 } else {
161 163
                     $this->current = new Row($parsed);
162
-                    if ($this->header) $this->current->setHeaderRow($this->header);
164
+                    if ($this->header) {
165
+                        $this->current->setHeaderRow($this->header);
166
+                    }
163 167
                 }
164 168
             } catch (EndOfFileException $e) {
165 169
                 $this->current = false;
@@ -183,7 +187,9 @@  discard block
 block discarded – undo
183 187
         $eol = $f->lineTerminator;
184 188
         try {
185 189
             do {
186
-                if (!isset($lines)) $lines = array();
190
+                if (!isset($lines)) {
191
+                    $lines = array();
192
+                }
187 193
                 if (false === ($line = $this->source->readLine($eol))) {
188 194
                     throw new EndOfFileException("End of file reached: " . $this->source->getName());
189 195
                 }
@@ -191,7 +197,9 @@  discard block
 block discarded – undo
191 197
             } while ($this->inQuotedString(end($lines), $f->quoteChar, $f->escapeChar));
192 198
         } catch (EndOfFileException $e) {
193 199
             // only throw the exception if we don't already have lines in the buffer
194
-            if (!count($lines)) throw $e;
200
+            if (!count($lines)) {
201
+                throw $e;
202
+            }
195 203
         }
196 204
         return rtrim(implode($eol, $lines), $eol);
197 205
     }
@@ -211,14 +219,18 @@  discard block
 block discarded – undo
211 219
     {
212 220
         if (!empty($line)) {
213 221
             do {
214
-                if (!isset($i)) $i = 0;
222
+                if (!isset($i)) {
223
+                    $i = 0;
224
+                }
215 225
                 $c = $line[$i++];
216 226
                 if ($this->escape) {
217 227
                     $this->escape = false;
218 228
                     continue;
219 229
                 }
220 230
                 $this->escape = ($c == $escapeChar);
221
-                if ($c == $quoteChar) $this->open = !$this->open;
231
+                if ($c == $quoteChar) {
232
+                    $this->open = !$this->open;
233
+                }
222 234
             } while ($i < strlen($line));
223 235
         }
224 236
         return $this->open;
Please login to merge, or discard this patch.
src/CSVelte/CSVelte.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     {
124 124
         self::assertFileExists($filename);
125 125
         if (!is_readable($filename)) {
126
-            throw new IOException('Permission denied for: ' . $filename, IOException::ERR_FILE_PERMISSION_DENIED);
126
+            throw new IOException('Permission denied for: '.$filename, IOException::ERR_FILE_PERMISSION_DENIED);
127 127
         }
128 128
     }
129 129
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     protected static function assertFileExists($filename)
138 138
     {
139 139
         if (!file_exists($filename)) {
140
-            throw new IOException('File does not exist: ' . $filename, IOException::ERR_FILE_NOT_FOUND);
140
+            throw new IOException('File does not exist: '.$filename, IOException::ERR_FILE_NOT_FOUND);
141 141
         }
142 142
     }
143 143
 }
Please login to merge, or discard this patch.