Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions src/Builder/Excel/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

final class Loader implements StepBuilderInterface
{
private ?Node\Expr $persistent = null;
private ?Node\Expr $logger = null;

public function __construct(
private readonly Node\Expr $filePath,
private Node\Expr $sheetName
private readonly Node\Expr $sheetName
) {
}

Expand All @@ -34,9 +35,9 @@ public function withState(Node\Expr $state): self
return $this;
}

public function withSheet(Node\Expr $sheet): self
public function withWriter(Node\Expr $persistent): self
{
$this->sheetName = $sheet;
$this->persistent = $persistent;

return $this;
}
Expand All @@ -45,24 +46,9 @@ public function getNode(): Node
{
$arguments = [
new Node\Arg(
value: new Node\Expr\MethodCall(
new Node\Expr\StaticCall(
class: new Node\Name\FullyQualified(\Box\Spout\Writer\Common\Creator\WriterEntityFactory::class),
name: 'createXLSXWriter'
),
name: 'openToFile',
args: [
new Node\Arg(
value: $this->filePath,
),
]
),
value: $this->persistent,
name: new Node\Identifier('writer'),
),
new Node\Arg(
value: $this->sheetName,
name: new Node\Identifier('sheetName'),
),
new Node\Arg(
value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified(\Psr\Log\NullLogger::class)),
name: new Node\Identifier('logger'),
Expand Down
25 changes: 9 additions & 16 deletions src/Builder/Excel/MultipleFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

final class MultipleFileLoader implements StepBuilderInterface
{
private ?Node\Expr $persistent = null;
private ?Node\Expr $logger = null;

public function __construct(
Expand Down Expand Up @@ -57,28 +58,20 @@ public function withSafeMode(): self
return $this;
}

public function withWriter(Node\Expr $persistent): self
{
$this->persistent = $persistent;

return $this;
}

public function getNode(): Node
{
$arguments = [
new Node\Arg(
value: new Node\Expr\MethodCall(
new Node\Expr\StaticCall(
class: new Node\Name\FullyQualified(\Box\Spout\Writer\Common\Creator\WriterEntityFactory::class),
name: 'createXLSXWriter'
),
name: 'openToFile',
args: [
new Node\Arg(
value: $this->filePath
),
]
),
value: $this->persistent,
name: new Node\Identifier('writer'),
),
new Node\Arg(
value: $this->sheetName,
name: new Node\Identifier('sheetName'),
),
new Node\Arg(
value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified(\Psr\Log\NullLogger::class)),
name: new Node\Identifier('logger'),
Expand Down
25 changes: 9 additions & 16 deletions src/Builder/OpenDocument/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

final class Loader implements StepBuilderInterface
{
private ?Node\Expr $writer = null;
private ?Node\Expr $logger = null;

public function __construct(
Expand Down Expand Up @@ -41,28 +42,20 @@ public function withSheet(Node\Expr $sheet): self
return $this;
}

public function withWriter(Node\Expr $writer): self
{
$this->writer = $writer;

return $this;
}

public function getNode(): Node
{
$arguments = [
new Node\Arg(
value: new Node\Expr\MethodCall(
new Node\Expr\StaticCall(
class: new Node\Name\FullyQualified(\Box\Spout\Writer\Common\Creator\WriterEntityFactory::class),
name: 'createODSWriter'
),
name: 'openToFile',
args: [
new Node\Arg(
value: $this->filePath
),
]
),
value: $this->writer,
name: new Node\Identifier('writer'),
),
new Node\Arg(
value: $this->sheetName,
name: new Node\Identifier('sheetName'),
),
new Node\Arg(
value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified(\Psr\Log\NullLogger::class)),
name: new Node\Identifier('logger'),
Expand Down
25 changes: 9 additions & 16 deletions src/Builder/OpenDocument/MultipleFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

final class MultipleFileLoader implements StepBuilderInterface
{
private ?Node\Expr $writer = null;
private ?Node\Expr $logger = null;

public function __construct(
Expand Down Expand Up @@ -57,28 +58,20 @@ public function withSafeMode(): self
return $this;
}

public function withWriter(Node\Expr $writer): self
{
$this->writer = $writer;

return $this;
}

public function getNode(): Node
{
$arguments = [
new Node\Arg(
value: new Node\Expr\MethodCall(
new Node\Expr\StaticCall(
class: new Node\Name\FullyQualified(\Box\Spout\Writer\Common\Creator\WriterEntityFactory::class),
name: 'createODSWriter'
),
name: 'openToFile',
args: [
new Node\Arg(
value: $this->filePath
),
]
),
value: $this->writer,
name: new Node\Identifier('writer'),
),
new Node\Arg(
value: $this->sheetName,
name: new Node\Identifier('sheetName'),
),
new Node\Arg(
value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified(\Psr\Log\NullLogger::class)),
name: new Node\Identifier('logger'),
Expand Down
3 changes: 3 additions & 0 deletions src/Configuration/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function getConfigTreeBuilder(): TreeBuilder
->then(asExpression())
->end()
->end()
->booleanNode('persistent')
->defaultFalse()
->end()
->arrayNode('excel')
->children()
->scalarNode('sheet')
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function normalize(array $config): array
try {
return $this->processor->processConfiguration($this->configuration, $config);
} catch (Symfony\InvalidTypeException|Symfony\InvalidConfigurationException $exception) {
throw new Configurator\InvalidConfigurationException($exception->getMessage(), 0, $exception);
throw new InvalidConfigurationException($exception->getMessage(), 0, $exception);
}
}

Expand Down
Loading