@@ -56,7 +56,7 @@ |
||
56 | 56 | public function __construct($fields) |
57 | 57 | { |
58 | 58 | $this->setFields($fields) |
59 | - ->rewind(); |
|
59 | + ->rewind(); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | protected function setFields($fields) |
@@ -91,8 +91,8 @@ |
||
91 | 91 | public function __construct($input, $flavor = null) |
92 | 92 | { |
93 | 93 | $this->setSource($input) |
94 | - ->setFlavor($flavor) |
|
95 | - ->rewind(); |
|
94 | + ->setFlavor($flavor) |
|
95 | + ->rewind(); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -19,7 +19,6 @@ |
||
19 | 19 | if (if $file->hasHeader()) { |
20 | 20 | $header = $file->getHeader() |
21 | 21 | } |
22 | - |
|
23 | 22 | * you can instead simply call $header->getHeader() and handle this exception if |
24 | 23 | * said file has no header |
25 | 24 | * |
@@ -267,16 +267,16 @@ |
||
267 | 267 | return strlen($data); |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Seekability accessor. |
|
272 | - * |
|
273 | - * Despite the fact that any class that implements this interface must also |
|
274 | - * define methods such as seek, that is no guarantee that an |
|
275 | - * object will necessarily be seekable. This method should tell the user |
|
276 | - * whether a stream is, in fact, seekable. |
|
277 | - * |
|
278 | - * @return boolean True if seekable, false otherwise |
|
279 | - */ |
|
270 | + /** |
|
271 | + * Seekability accessor. |
|
272 | + * |
|
273 | + * Despite the fact that any class that implements this interface must also |
|
274 | + * define methods such as seek, that is no guarantee that an |
|
275 | + * object will necessarily be seekable. This method should tell the user |
|
276 | + * whether a stream is, in fact, seekable. |
|
277 | + * |
|
278 | + * @return boolean True if seekable, false otherwise |
|
279 | + */ |
|
280 | 280 | public function isSeekable() |
281 | 281 | { |
282 | 282 | return $this->seekable; |
@@ -267,16 +267,16 @@ |
||
267 | 267 | return strlen($data); |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Seekability accessor. |
|
272 | - * |
|
273 | - * Despite the fact that any class that implements this interface must also |
|
274 | - * define methods such as seek, that is no guarantee that an |
|
275 | - * object will necessarily be seekable. This method should tell the user |
|
276 | - * whether a stream is, in fact, seekable. |
|
277 | - * |
|
278 | - * @return boolean True if seekable, false otherwise |
|
279 | - */ |
|
270 | + /** |
|
271 | + * Seekability accessor. |
|
272 | + * |
|
273 | + * Despite the fact that any class that implements this interface must also |
|
274 | + * define methods such as seek, that is no guarantee that an |
|
275 | + * object will necessarily be seekable. This method should tell the user |
|
276 | + * whether a stream is, in fact, seekable. |
|
277 | + * |
|
278 | + * @return boolean True if seekable, false otherwise |
|
279 | + */ |
|
280 | 280 | public function isSeekable() |
281 | 281 | { |
282 | 282 | return $this->seekable; |
@@ -267,16 +267,16 @@ |
||
267 | 267 | return strlen($data); |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Seekability accessor. |
|
272 | - * |
|
273 | - * Despite the fact that any class that implements this interface must also |
|
274 | - * define methods such as seek, that is no guarantee that an |
|
275 | - * object will necessarily be seekable. This method should tell the user |
|
276 | - * whether a stream is, in fact, seekable. |
|
277 | - * |
|
278 | - * @return boolean True if seekable, false otherwise |
|
279 | - */ |
|
270 | + /** |
|
271 | + * Seekability accessor. |
|
272 | + * |
|
273 | + * Despite the fact that any class that implements this interface must also |
|
274 | + * define methods such as seek, that is no guarantee that an |
|
275 | + * object will necessarily be seekable. This method should tell the user |
|
276 | + * whether a stream is, in fact, seekable. |
|
277 | + * |
|
278 | + * @return boolean True if seekable, false otherwise |
|
279 | + */ |
|
280 | 280 | public function isSeekable() |
281 | 281 | { |
282 | 282 | return $this->seekable; |
@@ -290,20 +290,20 @@ discard block |
||
290 | 290 | throw new TasterException("quoteChar and delimiter cannot be determined", TasterException::ERR_QUOTE_AND_DELIM); |
291 | 291 | } |
292 | 292 | |
293 | - /** |
|
294 | - * Take a list of likely delimiter characters and find the one that occurs |
|
295 | - * the most consistent amount of times within the provided data. |
|
296 | - * |
|
297 | - * @param string The character(s) used for newlines |
|
298 | - * @return string One of four Flavor::QUOTING_* constants |
|
299 | - * @see \CSVelte\Flavor for possible quote style constants |
|
300 | - * @todo Refactor this method--It needs more thorough testing against a wider |
|
301 | - * variety of CSV data to be sure it works reliably. And I'm sure there |
|
302 | - * are many performance and logic improvements that could be made. This |
|
303 | - * is essentially a first draft. |
|
304 | - * @todo Can't use replaceQuotedSpecialChars rather than removeQuotedStrings |
|
305 | - * because the former requires u to know the delimiter |
|
306 | - */ |
|
293 | + /** |
|
294 | + * Take a list of likely delimiter characters and find the one that occurs |
|
295 | + * the most consistent amount of times within the provided data. |
|
296 | + * |
|
297 | + * @param string The character(s) used for newlines |
|
298 | + * @return string One of four Flavor::QUOTING_* constants |
|
299 | + * @see \CSVelte\Flavor for possible quote style constants |
|
300 | + * @todo Refactor this method--It needs more thorough testing against a wider |
|
301 | + * variety of CSV data to be sure it works reliably. And I'm sure there |
|
302 | + * are many performance and logic improvements that could be made. This |
|
303 | + * is essentially a first draft. |
|
304 | + * @todo Can't use replaceQuotedSpecialChars rather than removeQuotedStrings |
|
305 | + * because the former requires u to know the delimiter |
|
306 | + */ |
|
307 | 307 | protected function lickDelimiter($eol = "\n") |
308 | 308 | { |
309 | 309 | $frequencies = []; |
@@ -380,16 +380,16 @@ discard block |
||
380 | 380 | * which one has the best distribution, return that one. |
381 | 381 | */ |
382 | 382 | |
383 | - $decision = $dups->get($max); |
|
384 | - try { |
|
385 | - return $this->guessDelimByDistribution($decision, $eol); |
|
386 | - } catch (TasterException $e) { |
|
387 | - // if somehow we STILL can't come to a consensus, then fall back to a |
|
388 | - // "preferred delimiters" list... |
|
389 | - foreach ($this->delims as $key => $val) { |
|
383 | + $decision = $dups->get($max); |
|
384 | + try { |
|
385 | + return $this->guessDelimByDistribution($decision, $eol); |
|
386 | + } catch (TasterException $e) { |
|
387 | + // if somehow we STILL can't come to a consensus, then fall back to a |
|
388 | + // "preferred delimiters" list... |
|
389 | + foreach ($this->delims as $key => $val) { |
|
390 | 390 | if ($delim = array_search($val, $decision)) return $delim; |
391 | - } |
|
392 | - } |
|
391 | + } |
|
392 | + } |
|
393 | 393 | } |
394 | 394 | return $delims |
395 | 395 | ->sort() |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | })->map(function($dists) { |
447 | 447 | return $dists->average(); |
448 | 448 | })->sort() |
449 | - ->reverse() |
|
450 | - ->getKeyAtPosition(0)]; |
|
449 | + ->reverse() |
|
450 | + ->getKeyAtPosition(0)]; |
|
451 | 451 | } catch (Exception $e) { |
452 | 452 | throw new TasterException("delimiter cannot be determined by distribution", TasterException::ERR_DELIMITER); |
453 | 453 | } |
@@ -187,6 +187,7 @@ discard block |
||
187 | 187 | * replaceQuotedSpecialChars method which (at least to me) makes more sense. |
188 | 188 | * |
189 | 189 | * @param string The string to replace quoted strings within |
190 | + * @param string $data |
|
190 | 191 | * @return string The input string with quoted strings removed |
191 | 192 | * @todo Replace code that uses this method with the replaceQuotedSpecialChars |
192 | 193 | * method instead. I think it's cleaner. |
@@ -558,7 +559,7 @@ discard block |
||
558 | 559 | * Determine whether a particular string of data has quotes around it. |
559 | 560 | * |
560 | 561 | * @param string $data The data to check |
561 | - * @return boolean Whether the data is quoted or not |
|
562 | + * @return integer Whether the data is quoted or not |
|
562 | 563 | */ |
563 | 564 | protected function isQuoted($data) |
564 | 565 | { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * |
234 | 234 | * Creates and returns a Stream object for this resource |
235 | 235 | * |
236 | - * @return resource The underlying stream resource |
|
236 | + * @return Stream The underlying stream resource |
|
237 | 237 | */ |
238 | 238 | public function __invoke() |
239 | 239 | { |
@@ -853,6 +853,7 @@ discard block |
||
853 | 853 | * only be called on unopened stream resources. |
854 | 854 | * |
855 | 855 | * @param string The method that is asserting |
856 | + * @param string $method |
|
856 | 857 | * @return void |
857 | 858 | * @throws \CSVelte\Exception\IOException if stream is open |
858 | 859 | */ |
@@ -869,6 +870,7 @@ discard block |
||
869 | 870 | * Used internally to ensure that a given stream wrapper is valid and available |
870 | 871 | * |
871 | 872 | * @param string The name of the stream wrapper |
873 | + * @param string $name |
|
872 | 874 | * @return void |
873 | 875 | * @throws \InvalidArgumentException if wrapper doesn't exist |
874 | 876 | */ |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | |
186 | 186 | // ok we're opening a new stream resource handle |
187 | 187 | $this->setUri($uri) |
188 | - ->setMode($mode) |
|
189 | - ->setLazy($lazy) |
|
190 | - ->setUseIncludePath($use_include_path) |
|
191 | - ->setContext($context_options, $context_params); |
|
188 | + ->setMode($mode) |
|
189 | + ->setLazy($lazy) |
|
190 | + ->setUseIncludePath($use_include_path) |
|
191 | + ->setContext($context_options, $context_params); |
|
192 | 192 | if (!$this->isLazy()) { |
193 | 193 | $this->connect(); |
194 | 194 | } |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | |
352 | 352 | $this->flag = ''; |
353 | 353 | $this->setBaseMode($base) |
354 | - ->setIsPlus($plus == '+') |
|
355 | - ->setIsText($flag == 't') |
|
356 | - ->setIsBinary($flag == 'b'); |
|
354 | + ->setIsPlus($plus == '+') |
|
355 | + ->setIsText($flag == 't') |
|
356 | + ->setIsBinary($flag == 'b'); |
|
357 | 357 | |
358 | 358 | return $this; |
359 | 359 | } |