@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | /** |
260 | 260 | * Closes the stream and any underlying resources. |
261 | 261 | * |
262 | - * @return void |
|
262 | + * @return boolean |
|
263 | 263 | */ |
264 | 264 | public function close() |
265 | 265 | { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * |
278 | 278 | * After the stream has been detached, the stream is in an unusable state. |
279 | 279 | * |
280 | - * @return array|Resource Underlying PHP stream, if any |
|
280 | + * @return string Underlying PHP stream, if any |
|
281 | 281 | * @todo I'm not sure what detach is for so I don't know whether what I'm |
282 | 282 | * doing here is right. The reason I have the method at all is because |
283 | 283 | * psr7 StreamInterface has one.f |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | { |
240 | 240 | if (!$this->isConnected()) { |
241 | 241 | $e = null; |
242 | - $errhandler = function () use (&$e) { |
|
242 | + $errhandler = function() 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 | /** |
@@ -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 | } |