@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | * |
615 | 615 | * @param int|mixed The offset to set |
616 | 616 | * @param any The value to set it to |
617 | - * @return boolean |
|
617 | + * @return Collection |
|
618 | 618 | */ |
619 | 619 | public function offsetSet($offset, $value) |
620 | 620 | { |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | * Filter out unwanted items using a callback function. |
771 | 771 | * |
772 | 772 | * @param Callable $callback |
773 | - * @return CSVelte\Collection A new collection with filtered items removed |
|
773 | + * @return Collection A new collection with filtered items removed |
|
774 | 774 | */ |
775 | 775 | public function filter(Callable $callback) |
776 | 776 | { |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | * Returns an array where the key is a value in the collection and the value |
823 | 823 | * is the number of times that value appears in the collection. |
824 | 824 | * |
825 | - * @return CSVelte\Collection A collection of value frequencies (see description) |
|
825 | + * @return Collection A collection of value frequencies (see description) |
|
826 | 826 | */ |
827 | 827 | public function frequency() |
828 | 828 | { |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | * Returns a collection with duplicate values removed. If two-dimensional, |
847 | 847 | * then each array within the collection will have its duplicates removed. |
848 | 848 | * |
849 | - * @return CSVelte\Collection A new collection with duplicate values removed. |
|
849 | + * @return Collection A new collection with duplicate values removed. |
|
850 | 850 | */ |
851 | 851 | public function unique() |
852 | 852 | { |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * Returns a collection of arrays where the key is the duplicate value |
863 | 863 | * and the value is an array of keys from the original collection. |
864 | 864 | * |
865 | - * @return CSVelte\Collection A new collection with duplicate values. |
|
865 | + * @return Collection A new collection with duplicate values. |
|
866 | 866 | */ |
867 | 867 | public function duplicates() |
868 | 868 | { |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | * |
881 | 881 | * Get a new collection where the keys and values have been swapped. |
882 | 882 | * |
883 | - * @return CSVelte\Collection A new collection where keys/values have been swapped |
|
883 | + * @return Collection A new collection where keys/values have been swapped |
|
884 | 884 | */ |
885 | 885 | public function flip() |
886 | 886 | { |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | * first is the default. |
895 | 895 | * |
896 | 896 | * @param boolean Whether you want pairs in [k => v] rather than [k, v] format |
897 | - * @return CSVelte\Collection A collection of key/value pairs |
|
897 | + * @return Collection A collection of key/value pairs |
|
898 | 898 | */ |
899 | 899 | public function pairs($alt = false) |
900 | 900 | { |
@@ -1056,9 +1056,8 @@ discard block |
||
1056 | 1056 | * default it uses a case-insensitive natural order algorithm, but you can |
1057 | 1057 | * pass it any sorting algorithm you like. |
1058 | 1058 | * |
1059 | - * @param Callable $sort_func The sorting function you want to use |
|
1060 | 1059 | * @param boolean $preserve_keys Whether you want to preserve keys |
1061 | - * @return CSVelte\Collection A new collection sorted by $callback |
|
1060 | + * @return Collection A new collection sorted by $callback |
|
1062 | 1061 | */ |
1063 | 1062 | public function sort(Callable $callback = null, $preserve_keys = true) |
1064 | 1063 | { |
@@ -1088,7 +1087,7 @@ discard block |
||
1088 | 1087 | * @param string $key The key you want to order by |
1089 | 1088 | * @param Callable $cmp The sorting comparison algorithm to use |
1090 | 1089 | * @param boolean $preserve_keys Whether keys should be preserved |
1091 | - * @return CSVelte\Collection A new collection sorted by $cmp and $key |
|
1090 | + * @return Collection A new collection sorted by $cmp and $key |
|
1092 | 1091 | */ |
1093 | 1092 | public function orderBy($key, Callable $cmp = null, $preserve_keys = true) |
1094 | 1093 | { |
@@ -1112,13 +1111,16 @@ discard block |
||
1112 | 1111 | * trying to write a particular sorting algurithm that sorts forwards and back. |
1113 | 1112 | * |
1114 | 1113 | * @param boolean $preserve_keys Whether keys should be preserved |
1115 | - * @return CSVelte\Collection A new collection in reverse order |
|
1114 | + * @return Collection A new collection in reverse order |
|
1116 | 1115 | */ |
1117 | 1116 | public function reverse($preserve_keys = true) |
1118 | 1117 | { |
1119 | 1118 | return new self(array_reverse($this->data, $preserve_keys)); |
1120 | 1119 | } |
1121 | 1120 | |
1121 | + /** |
|
1122 | + * @param string $method |
|
1123 | + */ |
|
1122 | 1124 | protected function if2DMapInternalMethod($method) |
1123 | 1125 | { |
1124 | 1126 | if ($this->is2D()) { |
@@ -194,7 +194,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | /** |
177 | 177 | * Return the current position within the stream/readable |
178 | 178 | * |
179 | - * @return int The current position within readable |
|
179 | + * @return boolean The current position within readable |
|
180 | 180 | */ |
181 | 181 | public function tell() |
182 | 182 | { |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | /** |
229 | 229 | * Closes the stream and any underlying resources. |
230 | 230 | * |
231 | - * @return void |
|
231 | + * @return boolean |
|
232 | 232 | */ |
233 | 233 | public function close() |
234 | 234 | { |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * Write data to the output. |
279 | 279 | * |
280 | 280 | * @param string The data to write |
281 | - * @return int The number of bytes written |
|
281 | + * @return boolean The number of bytes written |
|
282 | 282 | */ |
283 | 283 | public function write($data) |
284 | 284 | { |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * |
220 | 220 | * Creates and returns a Stream object for this resource |
221 | 221 | * |
222 | - * @return resource The underlying stream resource |
|
222 | + * @return Stream The underlying stream resource |
|
223 | 223 | */ |
224 | 224 | public function __invoke() |
225 | 225 | { |
@@ -432,6 +432,7 @@ discard block |
||
432 | 432 | * until the user specifically requests it. |
433 | 433 | * |
434 | 434 | * @param boolean|null Whether or not to "lazily" open the stream |
435 | + * @param boolean|null $lazy |
|
435 | 436 | * @return $this |
436 | 437 | */ |
437 | 438 | protected function setLazy($lazy) |
@@ -841,6 +842,7 @@ discard block |
||
841 | 842 | * only be called on unopened stream resources. |
842 | 843 | * |
843 | 844 | * @param string The method that is asserting |
845 | + * @param string $method |
|
844 | 846 | * @return void |
845 | 847 | * @throws \CSVelte\Exception\IOException if stream is open |
846 | 848 | */ |
@@ -857,6 +859,7 @@ discard block |
||
857 | 859 | * Used internally to ensure that a given stream wrapper is valid and available |
858 | 860 | * |
859 | 861 | * @param string The name of the stream wrapper |
862 | + * @param string $name |
|
860 | 863 | * @return void |
861 | 864 | * @throws \InvalidArgumentException if wrapper doesn't exist |
862 | 865 | */ |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | { |
240 | 240 | if (!$this->isConnected()) { |
241 | 241 | $e = null; |
242 | - $errhandler = function ($errno, $errstr, $errfile, $errline) use (&$e) { |
|
242 | + $errhandler = function($errno, $errstr, $errfile, $errline) use (&$e) { |
|
243 | 243 | $e = new IOException(sprintf( |
244 | 244 | "Could not open connection for %s using mode %s.", |
245 | 245 | $this->getUri(), |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | $this->updateContext(); |
556 | 556 | return $this; |
557 | 557 | } |
558 | - throw new InvalidArgumentException("Context options must be an array, got: " . gettype($options)); |
|
558 | + throw new InvalidArgumentException("Context options must be an array, got: ".gettype($options)); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | $this->updateContext(); |
576 | 576 | return $this; |
577 | 577 | } |
578 | - throw new InvalidArgumentException("Context parameters must be an array, got: " . gettype($params)); |
|
578 | + throw new InvalidArgumentException("Context parameters must be an array, got: ".gettype($params)); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
@@ -131,6 +131,7 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @see http://php.net/manual/en/function.fopen.php |
133 | 133 | * @see http://php.net/manual/en/function.stream-context-create.php |
134 | + * @param string $mode |
|
134 | 135 | */ |
135 | 136 | public static function open($uri, $mode = null, $context = null, $lazy = false) |
136 | 137 | { |
@@ -143,7 +144,7 @@ discard block |
||
143 | 144 | /** |
144 | 145 | * Close stream resource. |
145 | 146 | * |
146 | - * @return boolean True on success or false on failure |
|
147 | + * @return boolean|null True on success or false on failure |
|
147 | 148 | */ |
148 | 149 | public function close() |
149 | 150 | { |
@@ -224,7 +225,7 @@ discard block |
||
224 | 225 | * |
225 | 226 | * Returns the internal stream resource pointer |
226 | 227 | * |
227 | - * @return resource The open stream resource pointer |
|
228 | + * @return Resource The open stream resource pointer |
|
228 | 229 | */ |
229 | 230 | public function getResource() |
230 | 231 | { |
@@ -262,7 +263,7 @@ discard block |
||
262 | 263 | * |
263 | 264 | * After the stream has been detached, the stream is in an unusable state. |
264 | 265 | * |
265 | - * @return resource|null Underlying PHP stream, if any |
|
266 | + * @return Resource Underlying PHP stream, if any |
|
266 | 267 | */ |
267 | 268 | public function detach() |
268 | 269 | { |
@@ -189,6 +189,7 @@ discard block |
||
189 | 189 | * replaceQuotedSpecialChars method which (at least to me) makes more sense. |
190 | 190 | * |
191 | 191 | * @param string The string to replace quoted strings within |
192 | + * @param string $data |
|
192 | 193 | * @return string The input string with quoted strings removed |
193 | 194 | * @todo Replace code that uses this method with the replaceQuotedSpecialChars |
194 | 195 | * method instead. I think it's cleaner. |
@@ -559,7 +560,7 @@ discard block |
||
559 | 560 | * Determine whether a particular string of data has quotes around it. |
560 | 561 | * |
561 | 562 | * @param string The data to check |
562 | - * @return boolean Whether the data is quoted or not |
|
563 | + * @return integer Whether the data is quoted or not |
|
563 | 564 | */ |
564 | 565 | protected function isQuoted($data) |
565 | 566 | { |
@@ -607,6 +608,8 @@ discard block |
||
607 | 608 | * |
608 | 609 | * @param string The string to do the replacements on |
609 | 610 | * @param string The delimiter character to replace |
611 | + * @param string $data |
|
612 | + * @param string $delim |
|
610 | 613 | * @return string The data with replacements performed |
611 | 614 | * @todo I could probably pass in (maybe optionally) the newline character I |
612 | 615 | * want to replace as well. I'll do that if I need to. |
@@ -632,6 +635,7 @@ discard block |
||
632 | 635 | * to be practical. |
633 | 636 | * |
634 | 637 | * @param string The string of data to check the type of |
638 | + * @param string $data |
|
635 | 639 | * @return string One of the TYPE_ string constants above |
636 | 640 | */ |
637 | 641 | protected function lickType($data) |
@@ -215,16 +215,16 @@ discard block |
||
215 | 215 | { |
216 | 216 | $str = $this->removeQuotedStrings($this->sample); |
217 | 217 | $eols = [ |
218 | - self::EOL_WINDOWS => "\r\n", // 0x0D - 0x0A - Windows, DOS OS/2 |
|
219 | - self::EOL_UNIX => "\n", // 0x0A - - Unix, OSX |
|
220 | - self::EOL_TRS80 => "\r", // 0x0D - - Apple ][, TRS80 |
|
218 | + self::EOL_WINDOWS => "\r\n", // 0x0D - 0x0A - Windows, DOS OS/2 |
|
219 | + self::EOL_UNIX => "\n", // 0x0A - - Unix, OSX |
|
220 | + self::EOL_TRS80 => "\r", // 0x0D - - Apple ][, TRS80 |
|
221 | 221 | ]; |
222 | 222 | |
223 | 223 | $curCount = 0; |
224 | 224 | // @todo This should return a default maybe? |
225 | 225 | $curEol = PHP_EOL; |
226 | - foreach($eols as $k => $eol) { |
|
227 | - if( ($count = substr_count($str, $eol)) > $curCount) { |
|
226 | + foreach ($eols as $k => $eol) { |
|
227 | + if (($count = substr_count($str, $eol)) > $curCount) { |
|
228 | 228 | $curCount = $count; |
229 | 229 | $curEol = $eol; |
230 | 230 | } |
@@ -256,12 +256,12 @@ discard block |
||
256 | 256 | $patterns = []; |
257 | 257 | // delim can be anything but line breaks, quotes, alphanumeric, underscore, backslash, or any type of spaces |
258 | 258 | $antidelims = implode(array("\r", "\n", "\w", preg_quote('"', '/'), preg_quote("'", '/')/*, preg_quote('\\', '/')*/, preg_quote(chr(self::SPACE), '/'))); |
259 | - $delim = '(?P<delim>[^' . $antidelims . '])'; |
|
259 | + $delim = '(?P<delim>[^'.$antidelims.'])'; |
|
260 | 260 | $quote = '(?P<quoteChar>"|\'|`)'; // @todo I think MS Excel uses some strange encoding for fancy open/close quotes |
261 | - $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 |
|
262 | - $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 |
|
263 | - $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 |
|
264 | - $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 |
|
261 | + $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 |
|
262 | + $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 |
|
263 | + $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 |
|
264 | + $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 |
|
265 | 265 | foreach ($patterns as $pattern) { |
266 | 266 | // @todo I had to add the error suppression char here because it was |
267 | 267 | // causing undefined offset errors with certain data sets. strange... |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | if ($types->contains(self::DATA_NONNUMERIC)) { |
531 | 531 | // allow for a SMALL amount of error here |
532 | 532 | $counts = collect([self::DATA_SPECIAL => 0, self::DATA_NONNUMERIC => 0]); |
533 | - $freq->get('quoted')->walk(function ($type) use (&$counts) { |
|
533 | + $freq->get('quoted')->walk(function($type) use (&$counts) { |
|
534 | 534 | $counts->increment($type); |
535 | 535 | }); |
536 | 536 | // @todo is all this even necessary? seems unnecessary to me... |
@@ -651,13 +651,13 @@ discard block |
||
651 | 651 | $day = '[0-3]?[0-9]'; |
652 | 652 | $sep = '[\/\.\-]?'; |
653 | 653 | $time = '([0-2]?[0-9](:[0-5][0-9]){1,2}(am|pm)?|[01]?[0-9](am|pm))'; |
654 | - $date = '(' . $month . $sep . $day . $sep . $year . '|' . $day . $sep . $month . $sep . $year . '|' . $year . $sep . $month . $sep . $day . ')'; |
|
654 | + $date = '('.$month.$sep.$day.$sep.$year.'|'.$day.$sep.$month.$sep.$year.'|'.$year.$sep.$month.$sep.$day.')'; |
|
655 | 655 | $dt = new DateTime($data); |
656 | - $dt->setTime(0,0,0); |
|
656 | + $dt->setTime(0, 0, 0); |
|
657 | 657 | $now = new DateTime(); |
658 | - $now->setTime(0,0,0); |
|
658 | + $now->setTime(0, 0, 0); |
|
659 | 659 | $diff = $dt->diff($now); |
660 | - $diffDays = (integer) $diff->format( "%R%a" ); |
|
660 | + $diffDays = (integer) $diff->format("%R%a"); |
|
661 | 661 | if ($diffDays === 0) { |
662 | 662 | // then this is most likely a time string... |
663 | 663 | if (preg_match("/^{$time}$/i", $data)) { |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | } |
667 | 667 | if (preg_match("/^{$date}$/i", $data)) { |
668 | 668 | return self::TYPE_DATE; |
669 | - } elseif(preg_match("/^{$date} {$time}$/i")) { |
|
669 | + } elseif (preg_match("/^{$date} {$time}$/i")) { |
|
670 | 670 | return self::TYPE_DATETIME; |
671 | 671 | } |
672 | 672 | } catch (\Exception $e) { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * Class Constructor |
62 | 62 | * |
63 | - * @param \CSVelte\Contract\Writable $output An output source to write to |
|
63 | + * @param Streamable $output An output source to write to |
|
64 | 64 | * @param \CSVelte\Flavor|array $flavor A flavor or set of formatting params |
65 | 65 | */ |
66 | 66 | public function __construct(Streamable $output, $flavor = null) |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * likely buffer the output so that this may be called after writeRows() |
90 | 90 | * |
91 | 91 | * @param \Iterator|array A list of header values |
92 | - * @return boolean |
|
92 | + * @return boolean|null |
|
93 | 93 | * @throws \CSVelte\Exception\WriterException |
94 | 94 | */ |
95 | 95 | public function setHeaderRow($headers) |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * This means taking an array of data, and converting it to a Row object |
160 | 160 | * |
161 | 161 | * @param \Iterator|array of data items |
162 | - * @return CSVelte\Table\AbstractRow |
|
162 | + * @return Row |
|
163 | 163 | * @access protected |
164 | 164 | */ |
165 | 165 | protected function prepareRow(Iterator $row) |
@@ -187,6 +187,9 @@ discard block |
||
187 | 187 | return $this->quoteString($data); |
188 | 188 | } |
189 | 189 | |
190 | + /** |
|
191 | + * @param string $str |
|
192 | + */ |
|
190 | 193 | protected function quoteString($str) |
191 | 194 | { |
192 | 195 | $flvr = $this->getFlavor(); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | { |
142 | 142 | if (is_array($rows)) $rows = new ArrayIterator($rows); |
143 | 143 | if (!($rows instanceof Iterator)) { |
144 | - throw new InvalidArgumentException('First argument for ' . __METHOD__ . ' must be iterable'); |
|
144 | + throw new InvalidArgumentException('First argument for '.__METHOD__.' must be iterable'); |
|
145 | 145 | } |
146 | 146 | $written = 0; |
147 | 147 | if ($rows instanceof Reader) { |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | { |
166 | 166 | $items = array(); |
167 | 167 | foreach ($row as $data) { |
168 | - $items []= $this->prepareData($data); |
|
168 | + $items [] = $this->prepareData($data); |
|
169 | 169 | } |
170 | 170 | $row = new Row($items); |
171 | 171 | return $row; |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | // to use it for very long, in fact, once I finish writing the Data class |
194 | 194 | // it is gonezo! |
195 | 195 | $hasSpecialChars = function($s) use ($flvr) { |
196 | - $specialChars = preg_quote($flvr->lineTerminator . $flvr->quoteChar . $flvr->delimiter); |
|
196 | + $specialChars = preg_quote($flvr->lineTerminator.$flvr->quoteChar.$flvr->delimiter); |
|
197 | 197 | $pattern = "/[{$specialChars}]/m"; |
198 | 198 | return preg_match($pattern, $s); |
199 | 199 | }; |
200 | - switch($flvr->quoteStyle) { |
|
200 | + switch ($flvr->quoteStyle) { |
|
201 | 201 | case Flavor::QUOTE_ALL: |
202 | 202 | $doQuote = true; |
203 | 203 | break; |
@@ -227,6 +227,6 @@ discard block |
||
227 | 227 | $escapeQuote = ""; |
228 | 228 | if ($isQuoted) $escapeQuote = ($flvr->doubleQuote) ? $flvr->quoteChar : $flvr->escapeChar; |
229 | 229 | // @todo Not sure what else, if anything, I'm supposed to be escaping here.. |
230 | - return str_replace($flvr->quoteChar, $escapeQuote . $flvr->quoteChar, $str); |
|
230 | + return str_replace($flvr->quoteChar, $escapeQuote.$flvr->quoteChar, $str); |
|
231 | 231 | } |
232 | 232 | } |
@@ -73,7 +73,7 @@ |
||
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 | } |
@@ -192,7 +192,7 @@ discard block |
||
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 |
||
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() |
@@ -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 | } |