-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify
RenameEntriesTransformer
to work only on one entry
- Loading branch information
Showing
5 changed files
with
42 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
src/core/etl/src/Flow/ETL/Transformer/Rename/EntryRename.php
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
src/core/etl/src/Flow/ETL/Transformer/RenameEntriesTransformer.php
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
src/core/etl/src/Flow/ETL/Transformer/RenameEntryTransformer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Transformer; | ||
|
||
use Flow\ETL\FlowContext; | ||
use Flow\ETL\Row; | ||
use Flow\ETL\Rows; | ||
use Flow\ETL\Transformer; | ||
|
||
/** | ||
* @implements Transformer<array{from: string, to: string}> | ||
*/ | ||
final class RenameEntryTransformer implements Transformer | ||
{ | ||
public function __construct(private readonly string $from, private readonly string $to) | ||
{ | ||
} | ||
|
||
public function __serialize() : array | ||
{ | ||
return [ | ||
'from' => $this->from, | ||
'to' => $this->to, | ||
]; | ||
} | ||
|
||
public function __unserialize(array $data) : void | ||
{ | ||
$this->from = $data['from']; | ||
$this->to = $data['to']; | ||
} | ||
|
||
public function transform(Rows $rows, FlowContext $context) : Rows | ||
{ | ||
return $rows->map(fn (Row $row) : Row => $row->rename($this->from, $this->to)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters