@@ -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 | */ |
@@ -254,7 +254,9 @@ discard block |
||
254 | 254 | $this->getContext() |
255 | 255 | ); |
256 | 256 | restore_error_handler(); |
257 | - if ($e) throw $e; |
|
257 | + if ($e) { |
|
258 | + throw $e; |
|
259 | + } |
|
258 | 260 | } |
259 | 261 | return $this->isConnected(); |
260 | 262 | } |
@@ -328,7 +330,9 @@ discard block |
||
328 | 330 | public function setMode($mode = null) |
329 | 331 | { |
330 | 332 | $this->assertNotConnected(__METHOD__); |
331 | - if (is_null($mode)) $mode = "r+b"; |
|
333 | + if (is_null($mode)) { |
|
334 | + $mode = "r+b"; |
|
335 | + } |
|
332 | 336 | |
333 | 337 | $mode = substr($mode, 0, 3); |
334 | 338 | $rest = substr($mode, 1); |
@@ -436,7 +440,9 @@ discard block |
||
436 | 440 | */ |
437 | 441 | protected function setLazy($lazy) |
438 | 442 | { |
439 | - if (is_null($lazy)) $lazy = true; |
|
443 | + if (is_null($lazy)) { |
|
444 | + $lazy = true; |
|
445 | + } |
|
440 | 446 | $this->lazy = (boolean) $lazy; |
441 | 447 | return $this; |
442 | 448 | } |
@@ -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) |
@@ -169,7 +169,9 @@ discard block |
||
169 | 169 | try { |
170 | 170 | list($quoteChar, $delimiter) = $this->lickQuoteAndDelim(); |
171 | 171 | } catch (TasterException $e) { |
172 | - if ($e->getCode() !== TasterException::ERR_QUOTE_AND_DELIM) throw $e; |
|
172 | + if ($e->getCode() !== TasterException::ERR_QUOTE_AND_DELIM) { |
|
173 | + throw $e; |
|
174 | + } |
|
173 | 175 | $quoteChar = '"'; |
174 | 176 | $delimiter = $this->lickDelimiter($lineTerminator); |
175 | 177 | } |
@@ -265,7 +267,9 @@ discard block |
||
265 | 267 | foreach ($patterns as $pattern) { |
266 | 268 | // @todo I had to add the error suppression char here because it was |
267 | 269 | // causing undefined offset errors with certain data sets. strange... |
268 | - if (@preg_match_all($pattern, $this->sample, $matches) && $matches) break; |
|
270 | + if (@preg_match_all($pattern, $this->sample, $matches) && $matches) { |
|
271 | + break; |
|
272 | + } |
|
269 | 273 | } |
270 | 274 | if ($matches) { |
271 | 275 | try { |
@@ -388,7 +392,9 @@ discard block |
||
388 | 392 | // if somehow we STILL can't come to a consensus, then fall back to a |
389 | 393 | // "preferred delimiters" list... |
390 | 394 | foreach ($this->delims as $key => $val) { |
391 | - if ($delim = array_search($val, $decision)) return $delim; |
|
395 | + if ($delim = array_search($val, $decision)) { |
|
396 | + return $delim; |
|
397 | + } |
|
392 | 398 | } |
393 | 399 | } |
394 | 400 | } |
@@ -431,7 +437,9 @@ discard block |
||
431 | 437 | return $delims[collect($delims)->map(function($delim) use (&$distrib, $lines) { |
432 | 438 | $linedist = collect(); |
433 | 439 | $lines->walk(function($line, $line_no) use (&$linedist, $delim) { |
434 | - if (!strlen($line)) return; |
|
440 | + if (!strlen($line)) { |
|
441 | + return; |
|
442 | + } |
|
435 | 443 | $sectstot = 10; |
436 | 444 | $sectlen = (int) (strlen($line) / $sectstot); |
437 | 445 | $sections = collect(str_split($line, $sectlen)) |
@@ -519,8 +527,12 @@ discard block |
||
519 | 527 | $quoting_styles = $quoting_styles->filter(function($val) { return (bool) $val; }); |
520 | 528 | // if quoting_styles still has QUOTE_ALL or QUOTE_NONE, then return |
521 | 529 | // whichever of them it is, we don't need to do anything else |
522 | - if ($quoting_styles->has(Flavor::QUOTE_ALL)) return Flavor::QUOTE_ALL; |
|
523 | - if ($quoting_styles->has(Flavor::QUOTE_NONE)) return Flavor::QUOTE_NONE; |
|
530 | + if ($quoting_styles->has(Flavor::QUOTE_ALL)) { |
|
531 | + return Flavor::QUOTE_ALL; |
|
532 | + } |
|
533 | + if ($quoting_styles->has(Flavor::QUOTE_NONE)) { |
|
534 | + return Flavor::QUOTE_NONE; |
|
535 | + } |
|
524 | 536 | if (count($types) == 1) { |
525 | 537 | $style = $types->getValueAtPosition(0); |
526 | 538 | if ($quoting_styles->has($style)) { |
@@ -537,7 +549,9 @@ discard block |
||
537 | 549 | if ($most = $counts->max()) { |
538 | 550 | $least = $counts->min(); |
539 | 551 | $err_margin = $least / $most; |
540 | - if ($err_margin < 1) return Flavor::QUOTE_NONNUMERIC; |
|
552 | + if ($err_margin < 1) { |
|
553 | + return Flavor::QUOTE_NONNUMERIC; |
|
554 | + } |
|
541 | 555 | } |
542 | 556 | } |
543 | 557 | } |
@@ -712,7 +726,9 @@ discard block |
||
712 | 726 | $field = str_replace(self::PLACEHOLDER_DELIM, $delim, $field); |
713 | 727 | // @todo Need a Collection::setTableField($x, $y) method |
714 | 728 | // See notes in green binder about refactoring Collection |
715 | - if (!$types->has($line_no)) $types->set($line_no, collect()); |
|
729 | + if (!$types->has($line_no)) { |
|
730 | + $types->set($line_no, collect()); |
|
731 | + } |
|
716 | 732 | $types->get($line_no)->set($colpos, [ |
717 | 733 | 'type' => $this->lickType($this->unQuote($field)), |
718 | 734 | 'length' => strlen($field) |
@@ -735,12 +751,18 @@ discard block |
||
735 | 751 | extract($possibleHeader->get($col_no, null, true), EXTR_PREFIX_ALL, "header"); |
736 | 752 | if ($header_type == self::TYPE_STRING) { |
737 | 753 | // use length |
738 | - if ($length != $header_length) $hasHeader++; |
|
739 | - else $hasHeader--; |
|
754 | + if ($length != $header_length) { |
|
755 | + $hasHeader++; |
|
756 | + } else { |
|
757 | + $hasHeader--; |
|
758 | + } |
|
740 | 759 | } else { |
741 | 760 | // use data type |
742 | - if ($type != $header_type) $hasHeader++; |
|
743 | - else $hasHeader--; |
|
761 | + if ($type != $header_type) { |
|
762 | + $hasHeader++; |
|
763 | + } else { |
|
764 | + $hasHeader--; |
|
765 | + } |
|
744 | 766 | } |
745 | 767 | } catch (OutOfBoundsException $e) { |
746 | 768 | // failure... |
@@ -191,8 +191,9 @@ |
||
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 | /** |
@@ -45,7 +45,9 @@ |
||
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))) { |
@@ -104,7 +104,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -61,7 +61,9 @@ |
||
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 | } |
@@ -64,7 +64,9 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function __construct(Writable $output, $flavor = null) |
66 | 66 | { |
67 | - if (!($flavor instanceof Flavor)) $flavor = new Flavor($flavor); |
|
67 | + if (!($flavor instanceof Flavor)) { |
|
68 | + $flavor = new Flavor($flavor); |
|
69 | + } |
|
68 | 70 | $this->flavor = $flavor; |
69 | 71 | $this->output = $output; |
70 | 72 | } |
@@ -96,7 +98,9 @@ discard block |
||
96 | 98 | if ($this->written) { |
97 | 99 | throw new WriterException("Cannot set header row once data has already been written. "); |
98 | 100 | } |
99 | - if (is_array($headers)) $headers = new ArrayIterator($headers); |
|
101 | + if (is_array($headers)) { |
|
102 | + $headers = new ArrayIterator($headers); |
|
103 | + } |
|
100 | 104 | $this->headers = $headers; |
101 | 105 | } |
102 | 106 | |
@@ -114,7 +118,9 @@ discard block |
||
114 | 118 | $headerRow = new HeaderRow((array) $this->headers); |
115 | 119 | $this->writeHeaderRow($headerRow); |
116 | 120 | } |
117 | - if (is_array($row)) $row = new ArrayIterator($row); |
|
121 | + if (is_array($row)) { |
|
122 | + $row = new ArrayIterator($row); |
|
123 | + } |
|
118 | 124 | $row = $this->prepareRow($row); |
119 | 125 | if ($count = $this->output->writeLine($row->join($delim), $eol)) { |
120 | 126 | $this->written++; |
@@ -139,7 +145,9 @@ discard block |
||
139 | 145 | */ |
140 | 146 | public function writeRows($rows) |
141 | 147 | { |
142 | - if (is_array($rows)) $rows = new ArrayIterator($rows); |
|
148 | + if (is_array($rows)) { |
|
149 | + $rows = new ArrayIterator($rows); |
|
150 | + } |
|
143 | 151 | if (!($rows instanceof Iterator)) { |
144 | 152 | throw new InvalidArgumentException('First argument for ' . __METHOD__ . ' must be iterable'); |
145 | 153 | } |
@@ -148,7 +156,9 @@ discard block |
||
148 | 156 | $this->writeHeaderRow($rows->header()); |
149 | 157 | } |
150 | 158 | foreach ($rows as $row) { |
151 | - if ($this->writeRow($row)) $written++; |
|
159 | + if ($this->writeRow($row)) { |
|
160 | + $written++; |
|
161 | + } |
|
152 | 162 | } |
153 | 163 | return $written; |
154 | 164 | } |
@@ -225,7 +235,9 @@ discard block |
||
225 | 235 | { |
226 | 236 | $flvr = $this->getFlavor(); |
227 | 237 | $escapeQuote = ""; |
228 | - if ($isQuoted) $escapeQuote = ($flvr->doubleQuote) ? $flvr->quoteChar : $flvr->escapeChar; |
|
238 | + if ($isQuoted) { |
|
239 | + $escapeQuote = ($flvr->doubleQuote) ? $flvr->quoteChar : $flvr->escapeChar; |
|
240 | + } |
|
229 | 241 | // @todo Not sure what else, if anything, I'm supposed to be escaping here.. |
230 | 242 | return str_replace($flvr->quoteChar, $escapeQuote . $flvr->quoteChar, $str); |
231 | 243 | } |
@@ -136,7 +136,9 @@ discard block |
||
136 | 136 | { |
137 | 137 | $resource = (new Resource($uri, $mode)) |
138 | 138 | ->setContextResource($context); |
139 | - if (!$lazy) $resource->connect(); |
|
139 | + if (!$lazy) { |
|
140 | + $resource->connect(); |
|
141 | + } |
|
140 | 142 | return new self($resource); |
141 | 143 | } |
142 | 144 | |
@@ -169,7 +171,9 @@ discard block |
||
169 | 171 | } |
170 | 172 | // if a certain value was requested, return it |
171 | 173 | // otherwise, return entire array |
172 | - if (is_null($key)) return $this->meta; |
|
174 | + if (is_null($key)) { |
|
175 | + return $this->meta; |
|
176 | + } |
|
173 | 177 | return (array_key_exists($key, $this->meta)) ? $this->meta[$key] : null; |
174 | 178 | } |
175 | 179 | } |
@@ -315,7 +319,9 @@ discard block |
||
315 | 319 | public function read($length) |
316 | 320 | { |
317 | 321 | $this->assertIsReadable(); |
318 | - if ($this->eof()) return false; |
|
322 | + if ($this->eof()) { |
|
323 | + return false; |
|
324 | + } |
|
319 | 325 | return fread($this->resource->getHandle(), $length); |
320 | 326 | } |
321 | 327 |
@@ -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 | { |
@@ -153,8 +153,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -615,7 +615,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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()) { |