@@ -53,7 +53,10 @@ public function __construct(
53
53
$ this ->options = new CsvOptions ($ delimiter , $ enclosure , $ escapedBy );
54
54
$ this ->setSkipLines ($ skipLines );
55
55
$ this ->setFile ($ file );
56
+
56
57
$ this ->lineBreak = $ this ->detectLineBreak ();
58
+ $ this ->validateLineBreak ();
59
+
57
60
rewind ($ this ->filePointer );
58
61
$ this ->header = $ this ->readLine ();
59
62
$ this ->rewind ();
@@ -124,8 +127,6 @@ protected function detectLineBreak()
124
127
*/
125
128
protected function readLine ()
126
129
{
127
- $ this ->validateLineBreak ();
128
-
129
130
// allow empty enclosure hack
130
131
$ enclosure = !$ this ->getEnclosure () ? chr (0 ) : $ this ->getEnclosure ();
131
132
$ escapedBy = !$ this ->getEscapedBy () ? chr (0 ) : $ this ->getEscapedBy ();
@@ -138,15 +139,7 @@ protected function readLine()
138
139
*/
139
140
protected function validateLineBreak ()
140
141
{
141
- try {
142
- $ lineBreak = $ this ->getLineBreak ();
143
- } catch (Exception $ e ) {
144
- throw new InvalidArgumentException (
145
- "Failed to detect line break: " . $ e ->getMessage (),
146
- Exception::INVALID_PARAM ,
147
- $ e
148
- );
149
- }
142
+ $ lineBreak = $ this ->getLineBreak ();
150
143
if (in_array ($ lineBreak , ["\r\n" , "\n" ])) {
151
144
return $ lineBreak ;
152
145
}
0 commit comments