@@ -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')); |
@@ -13,7 +13,6 @@ discard block |
||
| 13 | 13 | namespace CSVelte; |
| 14 | 14 | |
| 15 | 15 | use CSVelte\Contract\Streamable; |
| 16 | - |
|
| 17 | 16 | use CSVelte\Exception\SnifferException; |
| 18 | 17 | use CSVelte\Sniffer\SniffDelimiterByConsistency; |
| 19 | 18 | use CSVelte\Sniffer\SniffDelimiterByDistribution; |
@@ -21,9 +20,7 @@ discard block |
||
| 21 | 20 | use CSVelte\Sniffer\SniffLineTerminatorByCount; |
| 22 | 21 | use CSVelte\Sniffer\SniffQuoteAndDelimByAdjacency; |
| 23 | 22 | use CSVelte\Sniffer\SniffQuoteStyle; |
| 24 | -use Noz\Collection\Collection; |
|
| 25 | 23 | use function Noz\to_array; |
| 26 | -use RuntimeException; |
|
| 27 | 24 | |
| 28 | 25 | use function Noz\collect; |
| 29 | 26 | use function Stringy\create as s; |
@@ -178,13 +178,13 @@ |
||
| 178 | 178 | |
| 179 | 179 | protected function sniffQuotingStyle($data, $delimiter, $lineTerminator) |
| 180 | 180 | { |
| 181 | - $sniffer = new SniffQuoteStyle(compact( 'lineTerminator', 'delimiter')); |
|
| 181 | + $sniffer = new SniffQuoteStyle(compact('lineTerminator', 'delimiter')); |
|
| 182 | 182 | return $sniffer->sniff($data); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | protected function sniffHasHeader($data, $delimiter, $lineTerminator) |
| 186 | 186 | { |
| 187 | - $sniffer = new SniffHeaderByDataType(compact( 'lineTerminator', 'delimiter')); |
|
| 187 | + $sniffer = new SniffHeaderByDataType(compact('lineTerminator', 'delimiter')); |
|
| 188 | 188 | return $sniffer->sniff($data); |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -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 | |