@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | use Traversable; |
16 | 16 | use function Noz\collect, |
17 | - Noz\to_array; |
|
17 | + Noz\to_array; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * CSV Dialect - Default dialect |
@@ -104,7 +104,7 @@ |
||
104 | 104 | if (property_exists($this, $attr)) { |
105 | 105 | // find the appropriate setter... |
106 | 106 | foreach (['set', 'setIs', 'setHas'] as $prefix) { |
107 | - $setter = $prefix . ucfirst(strtolower($attr)); |
|
107 | + $setter = $prefix.ucfirst(strtolower($attr)); |
|
108 | 108 | if (method_exists($this, $setter)) { |
109 | 109 | $this->{$setter}($val); |
110 | 110 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | } |
52 | 52 | $buffer .= $byte; |
53 | 53 | // Break when a new line is found or the max length - 1 is reached |
54 | - if (array_reduce($eol, function ($carry, $eol) use ($buffer) { |
|
54 | + if (array_reduce($eol, function($carry, $eol) use ($buffer) { |
|
55 | 55 | if (!$carry) { |
56 | 56 | $eollen = 0 - strlen($eol); |
57 | 57 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | public function writeLine($line, $eol = PHP_EOL) |
37 | 37 | { |
38 | - return $this->write($line . $eol); |
|
38 | + return $this->write($line.$eol); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | abstract public function isWritable(); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | if (!$this->isConnected()) { |
243 | 243 | /** @var IOException $e */ |
244 | 244 | $e = null; |
245 | - $errhandler = function () use (&$e) { |
|
245 | + $errhandler = function() use (&$e) { |
|
246 | 246 | $e = new IOException(sprintf( |
247 | 247 | 'Could not open connection for %s using mode %s', |
248 | 248 | $this->getUri(), |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | |
546 | 546 | return $this; |
547 | 547 | } |
548 | - throw new InvalidArgumentException('Context options must be an array, got: ' . gettype($options)); |
|
548 | + throw new InvalidArgumentException('Context options must be an array, got: '.gettype($options)); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | return $this; |
571 | 571 | } |
572 | - throw new InvalidArgumentException('Context parameters must be an array, got: ' . gettype($params)); |
|
572 | + throw new InvalidArgumentException('Context parameters must be an array, got: '.gettype($params)); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -35,9 +35,9 @@ |
||
35 | 35 | // in this case we really only care about newlines so we pass in a comma as the delim |
36 | 36 | $str = $this->replaceQuotedSpecialChars($data, ','); |
37 | 37 | $eols = [ |
38 | - static::EOL_WINDOWS => "\r\n", // 0x0D - 0x0A - Windows, DOS OS/2 |
|
39 | - static::EOL_UNIX => "\n", // 0x0A - - Unix, OSX |
|
40 | - static::EOL_OTHER => "\r", // 0x0D - - Other |
|
38 | + static::EOL_WINDOWS => "\r\n", // 0x0D - 0x0A - Windows, DOS OS/2 |
|
39 | + static::EOL_UNIX => "\n", // 0x0A - - Unix, OSX |
|
40 | + static::EOL_OTHER => "\r", // 0x0D - - Other |
|
41 | 41 | ]; |
42 | 42 | |
43 | 43 | $curCount = 0; |
@@ -20,18 +20,18 @@ |
||
20 | 20 | |
21 | 21 | class SniffQuoteAndDelimByAdjacency extends AbstractSniffer |
22 | 22 | { |
23 | - /** |
|
24 | - * Guess quote and delimiter character(s) |
|
25 | - * |
|
26 | - * If there are quoted values within the data, it is often easiest to guess the quote and delimiter characters at |
|
27 | - * the same time by analyzing their adjacency to one-another. That is to say, in cases where certain values are |
|
28 | - * wrapped in quotes, it can often be determined what not only that quote character is, but also the delimiter |
|
29 | - * because it is often on either side of the quote character. |
|
30 | - * |
|
31 | - * @param string $data The data to analyze |
|
32 | - * |
|
33 | - * @return string[] |
|
34 | - */ |
|
23 | + /** |
|
24 | + * Guess quote and delimiter character(s) |
|
25 | + * |
|
26 | + * If there are quoted values within the data, it is often easiest to guess the quote and delimiter characters at |
|
27 | + * the same time by analyzing their adjacency to one-another. That is to say, in cases where certain values are |
|
28 | + * wrapped in quotes, it can often be determined what not only that quote character is, but also the delimiter |
|
29 | + * because it is often on either side of the quote character. |
|
30 | + * |
|
31 | + * @param string $data The data to analyze |
|
32 | + * |
|
33 | + * @return string[] |
|
34 | + */ |
|
35 | 35 | public function sniff($data) |
36 | 36 | { |
37 | 37 | /** |
@@ -91,7 +91,7 @@ |
||
91 | 91 | * |
92 | 92 | * @param string $data The data to check |
93 | 93 | * |
94 | - * @return bool |
|
94 | + * @return integer |
|
95 | 95 | */ |
96 | 96 | protected function isQuoted($data) |
97 | 97 | { |
@@ -19,17 +19,17 @@ |
||
19 | 19 | |
20 | 20 | class SniffQuoteStyle extends AbstractSniffer |
21 | 21 | { |
22 | - /** |
|
23 | - * Guess quoting style |
|
24 | - * |
|
25 | - * The quoting style refers to which types of columns are quoted within a csv dataset. The dialect class defines |
|
26 | - * four possible quoting styles; all, none, minimal, or non-numeric. This class attempts to determine which of those |
|
27 | - * four it is by analyzing the content within each quoted value. |
|
28 | - * |
|
29 | - * @param string $data The data to analyze |
|
30 | - * |
|
31 | - * @return int |
|
32 | - */ |
|
22 | + /** |
|
23 | + * Guess quoting style |
|
24 | + * |
|
25 | + * The quoting style refers to which types of columns are quoted within a csv dataset. The dialect class defines |
|
26 | + * four possible quoting styles; all, none, minimal, or non-numeric. This class attempts to determine which of those |
|
27 | + * four it is by analyzing the content within each quoted value. |
|
28 | + * |
|
29 | + * @param string $data The data to analyze |
|
30 | + * |
|
31 | + * @return int |
|
32 | + */ |
|
33 | 33 | public function sniff($data) |
34 | 34 | { |
35 | 35 | $styles = collect([ |
@@ -64,7 +64,7 @@ |
||
64 | 64 | if (is_null($eol)) { |
65 | 65 | $eol = "\r\n|\r|\n"; |
66 | 66 | } |
67 | - return preg_replace_callback('/([\'"])(.*)\1/imsU', function ($matches) use ($delim, $eol) { |
|
67 | + return preg_replace_callback('/([\'"])(.*)\1/imsU', function($matches) use ($delim, $eol) { |
|
68 | 68 | $ret = preg_replace("/({$eol})/", static::PLACEHOLDER_NEWLINE, $matches[0]); |
69 | 69 | if (!is_null($delim)) { |
70 | 70 | $ret = str_replace($delim, static::PLACEHOLDER_DELIM, $ret); |
@@ -18,19 +18,19 @@ |
||
18 | 18 | |
19 | 19 | class SniffHeaderByDataType extends AbstractSniffer |
20 | 20 | { |
21 | - /** |
|
22 | - * Guess whether there is a header row |
|
23 | - * |
|
24 | - * Guesses whether the data has a header row by comparing the data types of the first row with the types of |
|
25 | - * corresponding columns in other rows. |
|
26 | - * |
|
27 | - * @note Unlike the original version of this method, this one will be used to ALSO determine HOW MANY header rows |
|
28 | - * there likely are. So, compare the header to rows at the END of the sample. |
|
29 | - * |
|
30 | - * @param string $data The data to analyze |
|
31 | - * |
|
32 | - * @return bool |
|
33 | - */ |
|
21 | + /** |
|
22 | + * Guess whether there is a header row |
|
23 | + * |
|
24 | + * Guesses whether the data has a header row by comparing the data types of the first row with the types of |
|
25 | + * corresponding columns in other rows. |
|
26 | + * |
|
27 | + * @note Unlike the original version of this method, this one will be used to ALSO determine HOW MANY header rows |
|
28 | + * there likely are. So, compare the header to rows at the END of the sample. |
|
29 | + * |
|
30 | + * @param string $data The data to analyze |
|
31 | + * |
|
32 | + * @return bool |
|
33 | + */ |
|
34 | 34 | public function sniff($data) |
35 | 35 | { |
36 | 36 | $delimiter = $this->getOption('delimiter'); |
@@ -73,7 +73,7 @@ |
||
73 | 73 | if (!$isHeader) { |
74 | 74 | // use standard deviation to determine if header is wildly different length than others |
75 | 75 | $mean = $length->average(); |
76 | - $sd = sqrt($length->map(function ($len) use ($mean) { |
|
76 | + $sd = sqrt($length->map(function($len) use ($mean) { |
|
77 | 77 | return pow($len - $mean, 2); |
78 | 78 | })->average()); |
79 | 79 |