@@ -34,7 +34,7 @@ use League\Csv\Reader;
34
34
use League\Csv\Statement;
35
35
36
36
$reader = Reader::createFromPath('/path/to/file.csv');
37
- $records = Statement::create( )->process($reader);
37
+ $records = (new Statement() )->process($reader);
38
38
// $records is a League\Csv\ResultSet instance
39
39
```
40
40
@@ -63,7 +63,7 @@ use League\Csv\Reader;
63
63
use League\Csv\Statement;
64
64
65
65
$reader = Reader::createFromPath('/path/to/file.csv');
66
- $records = Statement::create( )
66
+ $records = (new Statement() )
67
67
->where(fn (array $record): bool => false !== filter_var($record[2] ?? '', FILTER_VALIDATE_EMAIL))
68
68
->process($reader);
69
69
// $records is a League\Csv\ResultSet instance
@@ -88,7 +88,7 @@ use League\Csv\Reader;
88
88
use League\Csv\Statement;
89
89
90
90
$reader = Reader::createFromPath('/path/to/file.csv');
91
- $records = Statement::create( )
91
+ $records = (new Statement() )
92
92
->andWhere(1, '=', '10') //filtering is done of the second column
93
93
->orWhere('birthdate', 'regexp', '/\d{1,2}\/\d{1,2}\/\d{2,4}/') //filtering is done on the `birthdate` column
94
94
->whereNot('firstname', 'starts_with', 'P') //filtering is done case-sensitively on the first character of the column value
@@ -116,7 +116,7 @@ comparison is relaxed.
116
116
``` php
117
117
use League\Csv\Statement;
118
118
119
- $constraints = Statement::create( )->orWhere('direction', 'not in', ['east', 'north']);
119
+ $constraints = (new Statement() )->orWhere('direction', 'not in', ['east', 'north']);
120
120
```
121
121
122
122
The following parameter can only be used if the submitted value is a tuple
@@ -129,7 +129,7 @@ the range minimal value and the second argument, the range maximal value.
129
129
``` php
130
130
use League\Csv\Statement;
131
131
132
- $constraints = Statement::create( )->andWhere('points', 'between', [3, 5]);
132
+ $constraints = (new Statement() )->andWhere('points', 'between', [3, 5]);
133
133
```
134
134
135
135
The following parameters can only be used if the submitted value ** and** the column value are ` string ` .
@@ -160,7 +160,7 @@ use League\Csv\Statement;
160
160
$curDate = new DateTimeImmutable();
161
161
162
162
$reader = Reader::createFromPath('/path/to/file.csv');
163
- $records = Statement::create( )
163
+ $records = (new Statement() )
164
164
->andWhere(1, '=', '10') //filtering is done of the second column
165
165
->orWhere('birthdate', fn (string $value): bool => DateTimeImmutable::createFromFormat('Y-m-d', $value) < $curDate) //filtering is done on the `birthdate` column
166
166
->whereNot('firstname', 'starts_with', 'P') //filtering is done case-sensitively on the first character of the column value
@@ -180,7 +180,7 @@ use League\Csv\Reader;
180
180
use League\Csv\Statement;
181
181
182
182
$reader = Reader::createFromPath('/path/to/file.csv');
183
- $records = Statement::create( )
183
+ $records = (new Statement() )
184
184
->andWhereColumn('created_at', '<', 'update_at') //filtering is done on both column value
185
185
->whereNotColumn('fullname', 'starts_with', 4) //filtering is done on both column but the second column is specified via its offset
186
186
->process($reader);
@@ -195,7 +195,7 @@ use League\Csv\Reader;
195
195
use League\Csv\Statement;
196
196
197
197
$reader = Reader::createFromPath('/path/to/file.csv');
198
- $records = Statement::create( )
198
+ $records = (new Statement() )
199
199
->andWhereColumn('created_at', '<', 'update_at') //filtering is done on both column value
200
200
->andWhereOffset(
201
201
'fullname',
@@ -216,7 +216,7 @@ use League\Csv\Reader;
216
216
use League\Csv\Statement;
217
217
218
218
$reader = Reader::createFromPath('/path/to/file.csv');
219
- $records = Statement::create( )
219
+ $records = (new Statement() )
220
220
->andWhereOffset('<', 100) //filtering is done on the offset value only
221
221
->process($reader);
222
222
// $records is a League\Csv\ResultSet instance
@@ -231,7 +231,7 @@ use League\Csv\Reader;
231
231
use League\Csv\Statement;
232
232
233
233
$reader = Reader::createFromPath('/path/to/file.csv');
234
- $records = Statement::create( )
234
+ $records = (new Statement() )
235
235
->andWhereOffset(fn (string|int $value): bool => fmod((float) $value, 2) == 0)
236
236
// filtering is done on the record offset value
237
237
// records are kept only if the value is even.
@@ -279,7 +279,7 @@ use League\Csv\Reader;
279
279
use League\Csv\Statement;
280
280
281
281
$reader = Reader::createFromPath('/path/to/file.csv');
282
- $records = Statement::create( )
282
+ $records = (new Statement() )
283
283
->orderBy(fn (mixed $rA, mixed $rB): int => strcmp(Query\Row::from($rB)->field(1) ?? '', Query\Row::from($rA)->field(1) ?? '')))
284
284
->process($reader);
285
285
// $records is a League\Csv\ResultSet instance
@@ -303,7 +303,7 @@ use League\Csv\Reader;
303
303
use League\Csv\Statement;
304
304
305
305
$reader = Reader::createFromPath('/path/to/file.csv');
306
- $records = Statement::create( )
306
+ $records = (new Statement() )
307
307
->orderByDesc(1) //descending order according to the data of the 2nd column
308
308
->orderByAsc('foo', strcmp(...)) //ascending order according a callback compare function
309
309
->process($reader);
@@ -325,7 +325,7 @@ $sort = Query\Ordering\MultiSort::all(
325
325
);
326
326
327
327
$reader = Reader::createFromPath('/path/to/file.csv');
328
- $records = Statement::create( )->orderBy($sort)->process($reader);
328
+ $records = (new Statement() )->orderBy($sort)->process($reader);
329
329
// Will return the same content as in the previous example.
330
330
```
331
331
@@ -343,7 +343,7 @@ use League\Csv\Reader;
343
343
use League\Csv\Statement;
344
344
345
345
$reader = Reader::createFromPath('/path/to/file.csv');
346
- $records = Statement::create( )
346
+ $records = (new Statement() )
347
347
->limit(5)
348
348
->offset(9)
349
349
->process($reader);
@@ -366,7 +366,7 @@ use League\Csv\Reader;
366
366
use League\Csv\Statement;
367
367
368
368
$reader = Reader::createFromPath('/path/to/file.csv');
369
- $records = Statement::create( )
369
+ $records = (new Statement() )
370
370
->select(1, 3, 'field')
371
371
->process($reader);
372
372
// $records is a League\Csv\ResultSet instance with only 3 fields
@@ -379,7 +379,7 @@ to query your CSV document as you want like in the following example.
379
379
use League\Csv\Reader;
380
380
use League\Csv\Statement;
381
381
382
- $constraints = Statement::create( )
382
+ $constraints = (new Statement() )
383
383
->select('Integer', 'Text', 'Date and Time')
384
384
->andWhere('Float', '<', 1.3)
385
385
->orderByDesc('Integer')
@@ -410,7 +410,7 @@ In the event where you have a lot of fields to select but a few to remove you ma
410
410
to select all the fields except the one you will specify as argument to the method:
411
411
412
412
``` php
413
- $constraints = Statement::create( )
413
+ $constraints = (new Statement() )
414
414
->selectAllExcept('Integer')
415
415
->andWhere('Float', '<', 1.3)
416
416
->orderByDesc('Integer')
@@ -435,7 +435,7 @@ statement, both methods are mutually exclusive.</p>
435
435
The ` Statement::class ` now allows the building or the CSV query using conditions.
436
436
437
437
``` php
438
- $stmt = Statement::create( );
438
+ $stmt = (new Statement() );
439
439
if ($condition) {
440
440
$stmt = $stmt->where(fn (array $row) => $row['column'] !== 'data');
441
441
} else {
@@ -446,7 +446,7 @@ if ($condition) {
446
446
becomes
447
447
448
448
``` php
449
- $stmt = Statement::create( )
449
+ $stmt = (new Statement() )
450
450
->when(
451
451
$condition,
452
452
fn (Statement $q) => $q->where(fn (array $row) => $row['column'] !== 'data'),
@@ -516,7 +516,7 @@ use League\Csv\Reader;
516
516
use League\Csv\FragmentFinder;
517
517
518
518
$reader = Reader::createFromPath('/path/to/file.csv');
519
- $finder = FragmentFinder::create ();
519
+ $finder = new FragmentFinder();
520
520
521
521
$finder->find('row=7-5;8-9', $reader); // return an Iterator<TabularDataReader >
522
522
$finder->findFirst('row=7-5;8-9', $reader); // return an TabularDataReader
0 commit comments