@@ -123,7 +123,7 @@ discard block |
||
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 |
||
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 | } |
@@ -40,7 +40,7 @@ |
||
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 | /** |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function toArray() |
256 | 256 | { |
257 | - return array_map(function ($row) { |
|
257 | + return array_map(function($row) { |
|
258 | 258 | return $row->toArray(); |
259 | 259 | }, iterator_to_array($this)); |
260 | 260 | } |
@@ -387,12 +387,12 @@ discard block |
||
387 | 387 | if (!isset($i)) { |
388 | 388 | $i = 0; |
389 | 389 | } |
390 | - $c = $line[$i++]; |
|
390 | + $c = $line[$i++]; |
|
391 | 391 | if ($this->escape) { |
392 | 392 | $this->escape = false; |
393 | 393 | continue; |
394 | 394 | } |
395 | - $this->escape = ($c == $escapeChar); |
|
395 | + $this->escape = ($c == $escapeChar); |
|
396 | 396 | if ($c == $quoteChar) { |
397 | 397 | $this->open = !$this->open; |
398 | 398 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | */ |
429 | 429 | protected function replaceQuotedSpecialChars($data, $delim, $quo, $eol) |
430 | 430 | { |
431 | - return preg_replace_callback('/([' . preg_quote($quo, '/') . '])(.*)\1/imsU', function ($matches) use ($delim, $eol) { |
|
431 | + return preg_replace_callback('/(['.preg_quote($quo, '/').'])(.*)\1/imsU', function($matches) use ($delim, $eol) { |
|
432 | 432 | $ret = str_replace($eol, self::PLACEHOLDER_NEWLINE, $matches[0]); |
433 | 433 | $ret = str_replace($delim, self::PLACEHOLDER_DELIM, $ret); |
434 | 434 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | protected function undoReplaceQuotedSpecialChars($data, $delim, $eol) |
454 | 454 | { |
455 | 455 | $replacements = [self::PLACEHOLDER_DELIM => $delim, self::PLACEHOLDER_NEWLINE => $eol]; |
456 | - if (array_walk($replacements, function ($replacement, $placeholder) use (&$data) { |
|
456 | + if (array_walk($replacements, function($replacement, $placeholder) use (&$data) { |
|
457 | 457 | $data = str_replace($placeholder, $replacement, $data); |
458 | 458 | })) { |
459 | 459 | return $data; |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | */ |
498 | 498 | protected function unEscape($str, $esc, $quo) |
499 | 499 | { |
500 | - return str_replace($esc . $quo, $quo, $str); |
|
500 | + return str_replace($esc.$quo, $quo, $str); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | $columns = explode($f->delimiter, $replaced); |
517 | 517 | $that = $this; |
518 | 518 | |
519 | - return array_map(function ($val) use ($that, $f) { |
|
519 | + return array_map(function($val) use ($that, $f) { |
|
520 | 520 | $undone = $that->undoReplaceQuotedSpecialChars($val, $f->delimiter, $f->lineTerminator); |
521 | 521 | |
522 | 522 | return $this->unQuote($undone); |
@@ -242,7 +242,7 @@ |
||
242 | 242 | } elseif ($fields instanceof Iterator) { |
243 | 243 | $fields = iterator_to_array($fields); |
244 | 244 | } else { |
245 | - throw new InvalidArgumentException(__CLASS__ . ' requires an array, got: ' . gettype($fields)); |
|
245 | + throw new InvalidArgumentException(__CLASS__.' requires an array, got: '.gettype($fields)); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | $this->fields = collect(array_values($fields)); |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | if (in_array($rp, $paths)) { |
71 | 71 | return true; |
72 | 72 | } |
73 | - $this->paths []= $rp; |
|
73 | + $this->paths [] = $rp; |
|
74 | 74 | |
75 | 75 | return true; |
76 | 76 | } |
77 | - $this->paths []= $path; |
|
77 | + $this->paths [] = $path; |
|
78 | 78 | |
79 | 79 | return false; |
80 | 80 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $fqcp = str_replace(self::NAMESPACE_SEPARATOR, DIRECTORY_SEPARATOR, $className); |
133 | 133 | $paths = $this->getPaths(); |
134 | 134 | foreach ($paths as $path) { |
135 | - $classPath = $path . DIRECTORY_SEPARATOR . $fqcp . '.php'; |
|
135 | + $classPath = $path.DIRECTORY_SEPARATOR.$fqcp.'.php'; |
|
136 | 136 | if (file_exists($classPath) && is_readable($classPath)) { |
137 | 137 | require_once($classPath); |
138 | 138 |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | if (is_array($headers)) { |
115 | 115 | $headers = new ArrayIterator($headers); |
116 | 116 | } |
117 | - $this->headers = $headers; |
|
117 | + $this->headers = $headers; |
|
118 | 118 | |
119 | 119 | return $this; |
120 | 120 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | if (is_array($row)) { |
138 | 138 | $row = new ArrayIterator($row); |
139 | 139 | } |
140 | - $row = $this->prepareRow($row); |
|
140 | + $row = $this->prepareRow($row); |
|
141 | 141 | if ($count = $this->output->writeLine($row->join($delim), $eol)) { |
142 | 142 | $this->written++; |
143 | 143 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $rows = new ArrayIterator($rows); |
161 | 161 | } |
162 | 162 | if (!($rows instanceof Iterator)) { |
163 | - throw new InvalidArgumentException('First argument for ' . __METHOD__ . ' must be iterable'); |
|
163 | + throw new InvalidArgumentException('First argument for '.__METHOD__.' must be iterable'); |
|
164 | 164 | } |
165 | 165 | $written = 0; |
166 | 166 | if ($rows instanceof Reader) { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | { |
204 | 204 | $items = []; |
205 | 205 | foreach ($row as $data) { |
206 | - $items []= $this->prepareData($data); |
|
206 | + $items [] = $this->prepareData($data); |
|
207 | 207 | } |
208 | 208 | $row = new Row($items); |
209 | 209 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | // Normally I would make this a method on the class, but I don't intend |
241 | 241 | // to use it for very long, in fact, once I finish writing the Data class |
242 | 242 | // it is gonezo! |
243 | - $hasSpecialChars = function ($s) use ($flvr) { |
|
244 | - $specialChars = preg_quote($flvr->lineTerminator . $flvr->quoteChar . $flvr->delimiter); |
|
243 | + $hasSpecialChars = function($s) use ($flvr) { |
|
244 | + $specialChars = preg_quote($flvr->lineTerminator.$flvr->quoteChar.$flvr->delimiter); |
|
245 | 245 | $pattern = "/[{$specialChars}]/m"; |
246 | 246 | |
247 | 247 | return preg_match($pattern, $s); |
@@ -289,6 +289,6 @@ discard block |
||
289 | 289 | $escapeQuote = ($flvr->doubleQuote) ? $flvr->quoteChar : $flvr->escapeChar; |
290 | 290 | } |
291 | 291 | // @todo Not sure what else, if anything, I'm supposed to be escaping here.. |
292 | - return str_replace($flvr->quoteChar, $escapeQuote . $flvr->quoteChar, $str); |
|
292 | + return str_replace($flvr->quoteChar, $escapeQuote.$flvr->quoteChar, $str); |
|
293 | 293 | } |
294 | 294 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function __set($attr, $val) |
206 | 206 | { |
207 | - throw new ImmutableException('Cannot change attributes on an immutable object: ' . self::class . '::$' . $attr); |
|
207 | + throw new ImmutableException('Cannot change attributes on an immutable object: '.self::class.'::$'.$attr); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | protected function assertValidAttribute($attr) |
271 | 271 | { |
272 | 272 | if (!property_exists(self::class, $attr)) { |
273 | - throw new InvalidArgumentException('Unknown attribute: ' . $attr); |
|
273 | + throw new InvalidArgumentException('Unknown attribute: '.$attr); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | } |
61 | 61 | $buffer .= $byte; |
62 | 62 | // Break when a new line is found or the max length - 1 is reached |
63 | - if (array_reduce($eol, function ($carry, $eol) use ($buffer) { |
|
63 | + if (array_reduce($eol, function($carry, $eol) use ($buffer) { |
|
64 | 64 | if (!$carry) { |
65 | 65 | $eollen = 0 - strlen($eol); |
66 | 66 |
@@ -82,7 +82,7 @@ |
||
82 | 82 | */ |
83 | 83 | public function toArray() |
84 | 84 | { |
85 | - return array_map(function ($row) { |
|
85 | + return array_map(function($row) { |
|
86 | 86 | return $row->toArray(); |
87 | 87 | }, iterator_to_array($this)); |
88 | 88 | } |