@@ -692,7 +692,7 @@ |
||
692 | 692 | * |
693 | 693 | * @param string $data The data to check |
694 | 694 | * |
695 | - * @return bool Whether the data is quoted or not |
|
695 | + * @return integer Whether the data is quoted or not |
|
696 | 696 | */ |
697 | 697 | protected function isQuoted($data) |
698 | 698 | { |
@@ -14,13 +14,10 @@ |
||
14 | 14 | namespace CSVelte; |
15 | 15 | |
16 | 16 | use CSVelte\Collection\AbstractCollection; |
17 | -use CSVelte\Collection\Collection; |
|
18 | -use CSVelte\Collection\MultiCollection; |
|
19 | 17 | use CSVelte\Collection\NumericCollection; |
20 | 18 | use CSVelte\Collection\TabularCollection; |
21 | 19 | use CSVelte\Contract\Streamable; |
22 | 20 | use CSVelte\Exception\TasterException; |
23 | - |
|
24 | 21 | use DateTime; |
25 | 22 | use Exception; |
26 | 23 | use OutOfBoundsException; |
@@ -234,7 +234,9 @@ |
||
234 | 234 | // callback to build the aforementioned collection |
235 | 235 | $buildTypes = function ($line, $line_no) use ($types, $delim, $eol) { |
236 | 236 | |
237 | - if ($line_no > 2) return; |
|
237 | + if ($line_no > 2) { |
|
238 | + return; |
|
239 | + } |
|
238 | 240 | $line = str_replace(self::PLACEHOLDER_NEWLINE, $eol, $line); |
239 | 241 | $getType = function ($field, $colpos) use ($types, $line, $line_no, $delim) { |
240 | 242 | $field = str_replace(self::PLACEHOLDER_DELIM, $delim, $field); |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | return $this->guessDelimByDistribution($decision, $eol); |
514 | 514 | } catch (TasterException $e) { |
515 | 515 | // if somehow we STILL can't come to a consensus, then fall back to a |
516 | - // "preferred delimiters" list... |
|
517 | - foreach ($this->delims as $key => $chr) { |
|
518 | - if (collect($decision)->contains($chr)) { |
|
519 | - return $chr; |
|
520 | - } |
|
521 | - } |
|
516 | + // "preferred delimiters" list... |
|
517 | + foreach ($this->delims as $key => $chr) { |
|
518 | + if (collect($decision)->contains($chr)) { |
|
519 | + return $chr; |
|
520 | + } |
|
521 | + } |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | })->map(function ($dists) { |
589 | 589 | return $dists->average(); |
590 | 590 | })->sort() |
591 | - ->reverse() |
|
592 | - ->getKeyAtPosition(0)]; |
|
591 | + ->reverse() |
|
592 | + ->getKeyAtPosition(0)]; |
|
593 | 593 | } catch (Exception $e) { |
594 | 594 | throw new TasterException('delimiter cannot be determined by distribution', TasterException::ERR_DELIMITER); |
595 | 595 | } |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | $types = new TabularCollection(); |
234 | 234 | |
235 | 235 | // callback to build the aforementioned collection |
236 | - $buildTypes = function ($line, $line_no) use ($types, $delim, $eol) { |
|
236 | + $buildTypes = function($line, $line_no) use ($types, $delim, $eol) { |
|
237 | 237 | |
238 | 238 | if ($line_no > 2) return; |
239 | 239 | $line = str_replace(self::PLACEHOLDER_NEWLINE, $eol, $line); |
240 | - $getType = function ($field, $colpos) use ($types, $line, $line_no, $delim) { |
|
240 | + $getType = function($field, $colpos) use ($types, $line, $line_no, $delim) { |
|
241 | 241 | $field = str_replace(self::PLACEHOLDER_DELIM, $delim, $field); |
242 | 242 | $fieldMeta = [ |
243 | 243 | "value" => $field, |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | |
266 | 266 | $hasHeader = new NumericCollection(); |
267 | 267 | $possibleHeader = collect($types->shift()); |
268 | - $types->walk(function (AbstractCollection $row) use ($hasHeader, $possibleHeader) { |
|
269 | - $row->walk(function (AbstractCollection $fieldMeta, $col_no) use ($hasHeader, $possibleHeader) { |
|
268 | + $types->walk(function(AbstractCollection $row) use ($hasHeader, $possibleHeader) { |
|
269 | + $row->walk(function(AbstractCollection $fieldMeta, $col_no) use ($hasHeader, $possibleHeader) { |
|
270 | 270 | try { |
271 | 271 | $col = collect($possibleHeader->get($col_no, null, true)); |
272 | 272 | if ($fieldMeta->get('type') == self::TYPE_STRING) { |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | { |
331 | 331 | $str = $this->removeQuotedStrings($this->sample); |
332 | 332 | $eols = [ |
333 | - self::EOL_WINDOWS => "\r\n", // 0x0D - 0x0A - Windows, DOS OS/2 |
|
334 | - self::EOL_UNIX => "\n", // 0x0A - - Unix, OSX |
|
335 | - self::EOL_TRS80 => "\r", // 0x0D - - Apple ][, TRS80 |
|
333 | + self::EOL_WINDOWS => "\r\n", // 0x0D - 0x0A - Windows, DOS OS/2 |
|
334 | + self::EOL_UNIX => "\n", // 0x0A - - Unix, OSX |
|
335 | + self::EOL_TRS80 => "\r", // 0x0D - - Apple ][, TRS80 |
|
336 | 336 | ]; |
337 | 337 | |
338 | 338 | $curCount = 0; |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | $patterns = []; |
376 | 376 | // delim can be anything but line breaks, quotes, alphanumeric, underscore, backslash, or any type of spaces |
377 | 377 | $antidelims = implode(["\r", "\n", "\w", preg_quote('"', '/'), preg_quote("'", '/'), preg_quote(chr(self::SPACE), '/')]); |
378 | - $delim = '(?P<delim>[^' . $antidelims . '])'; |
|
378 | + $delim = '(?P<delim>[^'.$antidelims.'])'; |
|
379 | 379 | $quote = '(?P<quoteChar>"|\'|`)'; // @todo I think MS Excel uses some strange encoding for fancy open/close quotes |
380 | - $patterns[] = '/' . $delim . ' ?' . $quote . '.*?\2\1/ms'; // ,"something", - anything but whitespace or quotes followed by a possible space followed by a quote followed by anything followed by same quote, followed by same anything but whitespace |
|
381 | - $patterns[] = '/(?:^|\n)' . $quote . '.*?\1' . $delim . ' ?/ms'; // 'something', - beginning of line or line break, followed by quote followed by anything followed by quote followed by anything but whitespace or quotes |
|
382 | - $patterns[] = '/' . $delim . ' ?' . $quote . '.*?\2(?:^|\n)/ms'; // ,'something' - anything but whitespace or quote followed by possible space followed by quote followed by anything followed by quote, followed by end of line |
|
383 | - $patterns[] = '/(?:^|\n)' . $quote . '.*?\2(?:$|\n)/ms'; // 'something' - beginning of line followed by quote followed by anything followed by quote followed by same quote followed by end of line |
|
380 | + $patterns[] = '/'.$delim.' ?'.$quote.'.*?\2\1/ms'; // ,"something", - anything but whitespace or quotes followed by a possible space followed by a quote followed by anything followed by same quote, followed by same anything but whitespace |
|
381 | + $patterns[] = '/(?:^|\n)'.$quote.'.*?\1'.$delim.' ?/ms'; // 'something', - beginning of line or line break, followed by quote followed by anything followed by quote followed by anything but whitespace or quotes |
|
382 | + $patterns[] = '/'.$delim.' ?'.$quote.'.*?\2(?:^|\n)/ms'; // ,'something' - anything but whitespace or quote followed by possible space followed by quote followed by anything followed by quote, followed by end of line |
|
383 | + $patterns[] = '/(?:^|\n)'.$quote.'.*?\2(?:$|\n)/ms'; // 'something' - beginning of line followed by quote followed by anything followed by quote followed by same quote followed by end of line |
|
384 | 384 | foreach ($patterns as $pattern) { |
385 | 385 | // @todo I had to add the error suppression char here because it was |
386 | 386 | // causing undefined offset errors with certain data sets. strange... |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | } |
390 | 390 | } |
391 | 391 | if ($matches) { |
392 | - $qcad = array_intersect_key($matches, array_flip(['quoteChar','delim'])); |
|
392 | + $qcad = array_intersect_key($matches, array_flip(['quoteChar', 'delim'])); |
|
393 | 393 | if (!empty($matches['quoteChar']) && !empty($matches['delim'])) { |
394 | 394 | try { |
395 | 395 | return [ |
@@ -431,15 +431,15 @@ discard block |
||
431 | 431 | // each frequency (in 10 lines, "tab" occurred 5 times on 7 of those |
432 | 432 | // lines, 6 times on 2 lines, and 7 times on 1 line) |
433 | 433 | collect(explode($eol, $this->removeQuotedStrings($this->sample))) |
434 | - ->walk(function ($line, $line_no) use ($frequencies) { |
|
434 | + ->walk(function($line, $line_no) use ($frequencies) { |
|
435 | 435 | collect(str_split($line)) |
436 | - ->filter(function ($c) { |
|
436 | + ->filter(function($c) { |
|
437 | 437 | return collect($this->delims)->contains($c); |
438 | 438 | }) |
439 | 439 | ->frequency() |
440 | 440 | ->sort() |
441 | 441 | ->reverse() |
442 | - ->walk(function ($count, $char) use ($frequencies, $line_no) { |
|
442 | + ->walk(function($count, $char) use ($frequencies, $line_no) { |
|
443 | 443 | try { |
444 | 444 | $char_counts = $frequencies->get($char, null, true); |
445 | 445 | } catch (OutOfBoundsException $e) { |
@@ -452,8 +452,8 @@ discard block |
||
452 | 452 | // the above only finds frequencies for characters if they exist in |
453 | 453 | // a given line. This will go back and fill in zeroes where a char |
454 | 454 | // didn't occur at all in a given line (needed to determine mode) |
455 | - ->walk(function ($line, $line_no) use ($frequencies) { |
|
456 | - $frequencies->walk(function ($counts, $char) use ($line_no, $frequencies) { |
|
455 | + ->walk(function($line, $line_no) use ($frequencies) { |
|
456 | + $frequencies->walk(function($counts, $char) use ($line_no, $frequencies) { |
|
457 | 457 | try { |
458 | 458 | $char_counts = $frequencies->get($char, null, true); |
459 | 459 | } catch (OutOfBoundsException $e) { |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | foreach ($frequencies as $char => $freq) { |
473 | 473 | $modes->set($char, (new NumericCollection($freq))->mode()); |
474 | 474 | } |
475 | - $frequencies->walk(function ($f, $chr) use ($modes, $consistencies) { |
|
476 | - collect($f)->walk(function ($num) use ($modes, $chr, $consistencies) { |
|
475 | + $frequencies->walk(function($f, $chr) use ($modes, $consistencies) { |
|
476 | + collect($f)->walk(function($num) use ($modes, $chr, $consistencies) { |
|
477 | 477 | if ($expected = $modes->get($chr)) { |
478 | 478 | if ($num == $expected) { |
479 | 479 | // met the goal, yay! |
@@ -564,19 +564,19 @@ discard block |
||
564 | 564 | // @todo Write a method that does this... |
565 | 565 | $lines = collect(explode($eol, $this->removeQuotedStrings($this->sample))); |
566 | 566 | |
567 | - return $delims[collect($delims)->map(function ($delim) use (&$distrib, $lines) { |
|
567 | + return $delims[collect($delims)->map(function($delim) use (&$distrib, $lines) { |
|
568 | 568 | $linedist = collect(); |
569 | - $lines->walk(function ($line, $line_no) use (&$linedist, $delim) { |
|
569 | + $lines->walk(function($line, $line_no) use (&$linedist, $delim) { |
|
570 | 570 | if (!strlen($line)) { |
571 | 571 | return; |
572 | 572 | } |
573 | 573 | $sectstot = 10; |
574 | 574 | $sectlen = (int) (strlen($line) / $sectstot); |
575 | 575 | $sections = collect(str_split($line, $sectlen)) |
576 | - ->map(function ($section) use ($delim) { |
|
576 | + ->map(function($section) use ($delim) { |
|
577 | 577 | return substr_count($section, $delim); |
578 | 578 | }) |
579 | - ->filter(function ($count) { |
|
579 | + ->filter(function($count) { |
|
580 | 580 | return (bool) $count; |
581 | 581 | }); |
582 | 582 | if (is_numeric($count = $sections->count())) { |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | }); |
586 | 586 | |
587 | 587 | return $linedist; |
588 | - })->map(function ($dists) { |
|
588 | + })->map(function($dists) { |
|
589 | 589 | return $dists->average(); |
590 | 590 | })->sort() |
591 | 591 | ->reverse() |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | |
636 | 636 | // walk through each line from the data sample to determine which fields |
637 | 637 | // are quoted and which aren't |
638 | - $qsFunc = function ($line) use (&$quoting_styles, &$freq, $eol, $delim) { |
|
638 | + $qsFunc = function($line) use (&$quoting_styles, &$freq, $eol, $delim) { |
|
639 | 639 | $line = str_replace(self::PLACEHOLDER_NEWLINE, $eol, $line); |
640 | - $qnqaFunc = function ($field) use (&$quoting_styles, &$freq, $delim) { |
|
640 | + $qnqaFunc = function($field) use (&$quoting_styles, &$freq, $delim) { |
|
641 | 641 | $field = str_replace(self::PLACEHOLDER_DELIM, $delim, $field); |
642 | 642 | if ($this->isQuoted($field)) { |
643 | 643 | $field = $this->unQuote($field); |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | $lines->walk($qsFunc->bindTo($this)); |
659 | 659 | |
660 | 660 | $types = $freq->get('quoted')->unique(); |
661 | - $quoting_styles = $quoting_styles->filter(function ($val) { |
|
661 | + $quoting_styles = $quoting_styles->filter(function($val) { |
|
662 | 662 | return (bool) $val; |
663 | 663 | }); |
664 | 664 | // if quoting_styles still has QUOTE_ALL or QUOTE_NONE, then return |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | if ($types->contains(self::DATA_NONNUMERIC)) { |
679 | 679 | // allow for a SMALL amount of error here |
680 | 680 | $counts = collect([self::DATA_SPECIAL => 0, self::DATA_NONNUMERIC => 0]); |
681 | - $freq->get('quoted')->walk(function ($type) use (&$counts) { |
|
681 | + $freq->get('quoted')->walk(function($type) use (&$counts) { |
|
682 | 682 | $counts->increment($type); |
683 | 683 | }); |
684 | 684 | // @todo is all this even necessary? seems unnecessary to me... |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | */ |
772 | 772 | protected function replaceQuotedSpecialChars($data, $delim) |
773 | 773 | { |
774 | - return preg_replace_callback('/([\'"])(.*)\1/imsU', function ($matches) use ($delim) { |
|
774 | + return preg_replace_callback('/([\'"])(.*)\1/imsU', function($matches) use ($delim) { |
|
775 | 775 | $ret = preg_replace("/([\r\n])/", self::PLACEHOLDER_NEWLINE, $matches[0]); |
776 | 776 | $ret = str_replace($delim, self::PLACEHOLDER_DELIM, $ret); |
777 | 777 | |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | $day = '[0-3]?[0-9]'; |
812 | 812 | $sep = '[\/\.\-]?'; |
813 | 813 | $time = '([0-2]?[0-9](:[0-5][0-9]){1,2}(am|pm)?|[01]?[0-9](am|pm))'; |
814 | - $date = '(' . $month . $sep . $day . $sep . $year . '|' . $day . $sep . $month . $sep . $year . '|' . $year . $sep . $month . $sep . $day . ')'; |
|
814 | + $date = '('.$month.$sep.$day.$sep.$year.'|'.$day.$sep.$month.$sep.$year.'|'.$year.$sep.$month.$sep.$day.')'; |
|
815 | 815 | $dt = new DateTime($data); |
816 | 816 | $dt->setTime(0, 0, 0); |
817 | 817 | $now = new DateTime(); |
@@ -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 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | { |
245 | 245 | if (!$this->isConnected()) { |
246 | 246 | $e = null; |
247 | - $errhandler = function () use (&$e) { |
|
247 | + $errhandler = function() use (&$e) { |
|
248 | 248 | $e = new IOException(sprintf( |
249 | 249 | 'Could not open connection for %s using mode %s', |
250 | 250 | $this->getUri(), |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | |
544 | 544 | return $this; |
545 | 545 | } |
546 | - throw new InvalidArgumentException('Context options must be an array, got: ' . gettype($options)); |
|
546 | + throw new InvalidArgumentException('Context options must be an array, got: '.gettype($options)); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | |
568 | 568 | return $this; |
569 | 569 | } |
570 | - throw new InvalidArgumentException('Context parameters must be an array, got: ' . gettype($params)); |
|
570 | + throw new InvalidArgumentException('Context parameters must be an array, got: '.gettype($params)); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | /** |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | if (is_null($lazy)) { |
897 | 897 | $lazy = true; |
898 | 898 | } |
899 | - $this->lazy = (bool) $lazy; |
|
899 | + $this->lazy = (bool) $lazy; |
|
900 | 900 | |
901 | 901 | return $this; |
902 | 902 | } |