Passed
Push — releases/v0.3 ( 21cc01...7e799c )
by Luke
03:53
created
src/CSVelte/Sniffer.php 2 patches
Doc Comments   +9 added lines, -1 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      * @param string $data The data to analyze
154 154
      * @param string $lineTerminator The line terminator char/sequence
155 155
      *
156
-     * @return array A two-row array containing quotechar, delimchar
156
+     * @return string[] A two-row array containing quotechar, delimchar
157 157
      */
158 158
     protected function sniffQuoteAndDelim($data, $lineTerminator)
159 159
     {
@@ -163,6 +163,8 @@  discard block
 block discarded – undo
163 163
 
164 164
     /**
165 165
      * @todo To make this class more oop and test-friendly, implement strategy pattern here with each delim sniffing method implemented in its own strategy class.
166
+     * @param string|false $data
167
+     * @param string $lineTerminator
166 168
      */
167 169
     protected function sniffDelimiter($data, $lineTerminator)
168 170
     {
@@ -177,11 +179,17 @@  discard block
 block discarded – undo
177 179
         return current($winners);
178 180
     }
179 181
 
182
+    /**
183
+     * @param string $eols
184
+     */
180 185
     protected function sniffQuotingStyle($delimiter, $eols)
181 186
     {
182 187
         return Dialect::QUOTE_MINIMAL;
183 188
     }
184 189
 
190
+    /**
191
+     * @param string $eols
192
+     */
185 193
     protected function sniffHeader($delimiter, $eols)
186 194
     {
187 195
         return true;
Please login to merge, or discard this patch.
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -13,15 +13,12 @@
 block discarded – undo
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;
20 19
 use CSVelte\Sniffer\SniffLineTerminatorByCount;
21 20
 use CSVelte\Sniffer\SniffQuoteAndDelimByAdjacency;
22
-use Noz\Collection\Collection;
23 21
 use function Noz\to_array;
24
-use RuntimeException;
25 22
 
26 23
 use function Noz\collect;
27 24
 use function Stringy\create as s;
Please login to merge, or discard this patch.
src/CSVelte/Sniffer/SniffLineTerminatorByCount.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/CSVelte/Sniffer/SniffQuoteAndDelimByAdjacency.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@
 block discarded – undo
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
         /**
Please login to merge, or discard this patch.
src/CSVelte/Sniffer/AbstractSniffer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
         if (is_null($eol)) {
69 69
             $eol = "\r\n|\r|\n";
70 70
         }
71
-        return preg_replace_callback('/([\'"])(.*)\1/imsU', function ($matches) use ($delim, $eol) {
71
+        return preg_replace_callback('/([\'"])(.*)\1/imsU', function($matches) use ($delim, $eol) {
72 72
             $ret = preg_replace("/({$eol})/", self::PLACEHOLDER_NEWLINE, $matches[0]);
73 73
             if (!is_null($delim)) {
74 74
                 $ret = str_replace($delim, self::PLACEHOLDER_DELIM, $ret);
Please login to merge, or discard this patch.