@@ -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 |
@@ -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([ |
@@ -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'); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string $data The data to analyze |
156 | 156 | * @param string $lineTerminator The line terminator char/sequence |
157 | 157 | * |
158 | - * @return array A two-row array containing quotechar, delimchar |
|
158 | + * @return string[] A two-row array containing quotechar, delimchar |
|
159 | 159 | */ |
160 | 160 | protected function sniffQuoteAndDelim($data, $lineTerminator) |
161 | 161 | { |
@@ -163,6 +163,10 @@ discard block |
||
163 | 163 | return $sniffer->sniff($data); |
164 | 164 | } |
165 | 165 | |
166 | + /** |
|
167 | + * @param string|false $data |
|
168 | + * @param string $lineTerminator |
|
169 | + */ |
|
166 | 170 | protected function sniffDelimiter($data, $lineTerminator) |
167 | 171 | { |
168 | 172 | $delimiters = $this->getPossibleDelimiters(); |
@@ -176,12 +180,20 @@ discard block |
||
176 | 180 | return current($winners); |
177 | 181 | } |
178 | 182 | |
183 | + /** |
|
184 | + * @param string|false $data |
|
185 | + * @param string $lineTerminator |
|
186 | + */ |
|
179 | 187 | protected function sniffQuotingStyle($data, $delimiter, $lineTerminator) |
180 | 188 | { |
181 | 189 | $sniffer = new SniffQuoteStyle(compact( 'lineTerminator', 'delimiter')); |
182 | 190 | return $sniffer->sniff($data); |
183 | 191 | } |
184 | 192 | |
193 | + /** |
|
194 | + * @param string|false $data |
|
195 | + * @param string $lineTerminator |
|
196 | + */ |
|
185 | 197 | protected function sniffHasHeader($data, $delimiter, $lineTerminator) |
186 | 198 | { |
187 | 199 | $sniffer = new SniffHeaderByDataType(compact( 'lineTerminator', 'delimiter')); |