@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | if ($dialect === null) { |
| 66 | 66 | $dialect = []; |
| 67 | 67 | } else { |
| 68 | - $dialect = (array) $dialect; |
|
| 68 | + $dialect = (array)$dialect; |
|
| 69 | 69 | }; |
| 70 | 70 | $this->dialect = array_merge($defaultDialect, $dialect); |
| 71 | 71 | if (!in_array($this->dialect["lineTerminator"], ["\r\n", "\n\r", "\n", "\r"])) { |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $enclosed = null; |
| 101 | 101 | $fields = []; |
| 102 | 102 | $field = -1; |
| 103 | - $lastCharPos = mb_strlen($line)-1; |
|
| 103 | + $lastCharPos = mb_strlen($line) - 1; |
|
| 104 | 104 | for ($charPos = 0; $charPos < mb_strlen($line); $charPos++) { |
| 105 | 105 | $char = mb_substr($line, $charPos, 1); |
| 106 | 106 | if ($enclosed === null) { |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | // delimiter at end of line |
| 111 | 111 | ($charPos == $lastCharPos) |
| 112 | 112 | // double delimiters |
| 113 | - || ($charPos != $lastCharPos && mb_substr($line, $charPos+1, 1) == $this->dialect["delimiter"]) |
|
| 113 | + || ($charPos != $lastCharPos && mb_substr($line, $charPos + 1, 1) == $this->dialect["delimiter"]) |
|
| 114 | 114 | ) { |
| 115 | 115 | $field++; |
| 116 | 116 | $fields[$field] = ""; |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | // processing an enclosed field |
| 133 | 133 | if ($this->dialect["doubleQuote"] !== null && $char == $this->dialect["quoteChar"]) { |
| 134 | 134 | // encountered quote in doubleQuote mode |
| 135 | - if ($charPos !== 0 && mb_substr($line, $charPos-1, 1) == $this->dialect["quoteChar"]) { |
|
| 135 | + if ($charPos !== 0 && mb_substr($line, $charPos - 1, 1) == $this->dialect["quoteChar"]) { |
|
| 136 | 136 | // previous char was also a double quote |
| 137 | 137 | // the quote was added in previous iteration, nothing to do here |
| 138 | 138 | continue; |
| 139 | - } elseif ($charPos != $lastCharPos && mb_substr($line, $charPos+1, 1) == $this->dialect["quoteChar"]) { |
|
| 139 | + } elseif ($charPos != $lastCharPos && mb_substr($line, $charPos + 1, 1) == $this->dialect["quoteChar"]) { |
|
| 140 | 140 | // next char is a also a double quote - add a quote to the field |
| 141 | 141 | $fields[$field] .= $this->dialect["quoteChar"]; |
| 142 | 142 | continue; |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | if ($charPos === $lastCharPos) { |
| 150 | 150 | throw new DataSourceException("Encountered escape char at end of line"); |
| 151 | 151 | } else { |
| 152 | - $fields[$field] .= mb_substr($line, $charPos+1, 1); |
|
| 152 | + $fields[$field] .= mb_substr($line, $charPos + 1, 1); |
|
| 153 | 153 | } |
| 154 | 154 | continue; |
| 155 | - } elseif ($charPos != 0 && mb_substr($line, $charPos-1, 1) == $this->dialect["escapeChar"]) { |
|
| 155 | + } elseif ($charPos != 0 && mb_substr($line, $charPos - 1, 1) == $this->dialect["escapeChar"]) { |
|
| 156 | 156 | // previous char was the escape string |
| 157 | 157 | // added the char in previous iteration, nothing to do here |
| 158 | 158 | continue; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | // delimiter at end of line |
| 179 | 179 | ($charPos == $lastCharPos) |
| 180 | 180 | // double delimiters |
| 181 | - || ($charPos != $lastCharPos && mb_substr($line, $charPos+1, 1) == $this->dialect["delimiter"]) |
|
| 181 | + || ($charPos != $lastCharPos && mb_substr($line, $charPos + 1, 1) == $this->dialect["delimiter"]) |
|
| 182 | 182 | ) { |
| 183 | 183 | $field++; |
| 184 | 184 | $fields[$field] = ""; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | - if (count($fields) > 1 && mb_strlen($fields[count($fields)-1]) == 0) { |
|
| 195 | + if (count($fields) > 1 && mb_strlen($fields[count($fields) - 1]) == 0) { |
|
| 196 | 196 | throw new \Exception("Invalid csv file - line must not end with a comma"); |
| 197 | 197 | } |
| 198 | 198 | if ($this->dialect["skipInitialSpace"]) { |