Skip to content

Commit 4d87c31

Browse files
committed
Fixed multiple files loader, updated its name and updated its tests
1 parent 2d6d282 commit 4d87c31

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Kiboko\Contract\Configurator\StepBuilderInterface;
66
use PhpParser\Node;
77

8-
final class MultipleFileLoader implements StepBuilderInterface
8+
final class MultipleFilesLoader implements StepBuilderInterface
99
{
1010
private ?Node\Expr $logger;
1111
private ?Node\Expr $rejection;
@@ -217,7 +217,7 @@ class: new Node\Name\FullyQualified('SplFileObject'),
217217
new Node\Stmt\Expression(
218218
expr: new Node\Expr\Assign(
219219
var: new Node\Expr\Variable('readLines'),
220-
expr: new Node\Scalar\LNumber(1)
220+
expr: new Node\Scalar\LNumber(0)
221221
)
222222
),
223223
new Node\Stmt\Expression(
@@ -260,7 +260,7 @@ class: new Node\Name\FullyQualified('SplFileObject'),
260260
new Node\Stmt\Expression(
261261
new Node\Expr\Assign(
262262
new Node\Expr\Variable('readLines'),
263-
new Node\Scalar\LNumber(1),
263+
new Node\Scalar\LNumber(0),
264264
),
265265
),
266266
],

src/Factory/Loader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function validate(array $config): bool
5353
public function compile(array $config): Repository\Loader
5454
{
5555
if (array_key_exists('max_lines', $config)) {
56-
$loader = new CSV\Builder\MultipleFileLoader(
56+
$loader = new CSV\Builder\MultipleFilesLoader(
5757
filePath: compileValueWhenExpression($this->interpreter, $config['file_path'], 'index'),
5858
maxLines: compileValueWhenExpression($this->interpreter, $config['max_lines']),
5959
delimiter: array_key_exists('delimiter', $config) ? compileValueWhenExpression($this->interpreter, $config['delimiter']) : null,

src/Factory/Repository/Loader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ final class Loader implements Configurator\StepRepositoryInterface
99
{
1010
use RepositoryTrait;
1111

12-
public function __construct(private CSV\Builder\Loader|CSV\Builder\MultipleFileLoader $builder)
12+
public function __construct(private CSV\Builder\Loader|CSV\Builder\MultipleFilesLoader $builder)
1313
{
1414
$this->files = [];
1515
$this->packages = [];
1616
}
1717

18-
public function getBuilder(): CSV\Builder\Loader|CSV\Builder\MultipleFileLoader
18+
public function getBuilder(): CSV\Builder\Loader|CSV\Builder\MultipleFilesLoader
1919
{
2020
return $this->builder;
2121
}

tests/functional/Builder/MultipleFilesLoaderTest.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,19 @@ public function testWithoutOptions(): void
3333
firstname,lastname
3434
Pierre,Dupont
3535
John,Doe
36+
Frank,O'hara
3637
3738
CSV);
3839

3940
file_put_contents('vfs://expected-2.csv', <<<CSV
4041
firstname,lastname
41-
Frank,O'hara
4242
Hiroko,Froncillo
43+
Marlon,Botz
44+
Billy,Hess
4345
4446
CSV);
4547

46-
$loader = new Builder\MultipleFileLoader(
48+
$loader = new Builder\MultipleFilesLoader(
4749
filePath: compileExpression(new \functional\Kiboko\Plugin\CSV\ExpressionLanguage\ExpressionLanguage(), new Expression('format("vfs://SKU_%06d.csv", index)'), 'index'),
4850
maxLines: new Node\Scalar\LNumber(3)
4951
);
@@ -65,7 +67,19 @@ public function testWithoutOptions(): void
6567
[
6668
'firstname' => 'Hiroko',
6769
'lastname' => 'Froncillo',
68-
]
70+
],
71+
[
72+
'firstname' => 'Marlon',
73+
'lastname' => 'Botz',
74+
],
75+
[
76+
'firstname' => 'Billy',
77+
'lastname' => 'Hess',
78+
],
79+
[
80+
'firstname' => 'Henry',
81+
'lastname' => 'Sellers',
82+
],
6983
],
7084
[
7185
[
@@ -83,7 +97,19 @@ public function testWithoutOptions(): void
8397
[
8498
'firstname' => 'Hiroko',
8599
'lastname' => 'Froncillo',
86-
]
100+
],
101+
[
102+
'firstname' => 'Marlon',
103+
'lastname' => 'Botz',
104+
],
105+
[
106+
'firstname' => 'Billy',
107+
'lastname' => 'Hess',
108+
],
109+
[
110+
'firstname' => 'Henry',
111+
'lastname' => 'Sellers',
112+
],
87113
],
88114
$loader,
89115
);

0 commit comments

Comments
 (0)