diff --git a/src/core/etl/src/Flow/ETL/DSL/Transform.php b/src/core/etl/src/Flow/ETL/DSL/Transform.php index 5e72cf969..1a81522cb 100644 --- a/src/core/etl/src/Flow/ETL/DSL/Transform.php +++ b/src/core/etl/src/Flow/ETL/DSL/Transform.php @@ -16,8 +16,7 @@ use Flow\ETL\Transformer; use Flow\ETL\Transformer\ArrayKeysStyleConverterTransformer; use Flow\ETL\Transformer\KeepEntriesTransformer; -use Flow\ETL\Transformer\Rename\EntryRename; -use Flow\ETL\Transformer\RenameEntriesTransformer; +use Flow\ETL\Transformer\RenameEntryTransformer; use Flow\ETL\Transformer\StyleConverter\StringStyles; /** @@ -149,7 +148,7 @@ final public static function remove(string|Reference ...$entry) : Transformer final public static function rename(string $from, string $to) : Transformer { - return new RenameEntriesTransformer(new EntryRename($from, $to)); + return new RenameEntryTransformer($from, $to); } public static function rename_all_case(bool $upper = false, bool $lower = false, bool $ucfirst = false, bool $ucwords = false) : Transformer diff --git a/src/core/etl/src/Flow/ETL/Transformer/Rename/EntryRename.php b/src/core/etl/src/Flow/ETL/Transformer/Rename/EntryRename.php deleted file mode 100644 index 792dbc2fe..000000000 --- a/src/core/etl/src/Flow/ETL/Transformer/Rename/EntryRename.php +++ /dev/null @@ -1,41 +0,0 @@ - - */ -final class EntryRename implements Serializable -{ - public function __construct(private string $from, private 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 from() : string - { - return $this->from; - } - - public function to() : string - { - return $this->to; - } -} diff --git a/src/core/etl/src/Flow/ETL/Transformer/RenameEntriesTransformer.php b/src/core/etl/src/Flow/ETL/Transformer/RenameEntriesTransformer.php deleted file mode 100644 index 44b070c43..000000000 --- a/src/core/etl/src/Flow/ETL/Transformer/RenameEntriesTransformer.php +++ /dev/null @@ -1,47 +0,0 @@ -}> - */ -final class RenameEntriesTransformer implements Transformer -{ - /** - * @var Rename\EntryRename[] - */ - private readonly array $entryRenames; - - public function __construct(Transformer\Rename\EntryRename ...$entryRenames) - { - $this->entryRenames = $entryRenames; - } - - public function __serialize() : array - { - return [ - 'entry_renames' => $this->entryRenames, - ]; - } - - public function __unserialize(array $data) : void - { - $this->entryRenames = $data['entry_renames']; - } - - public function transform(Rows $rows, FlowContext $context) : Rows - { - foreach ($this->entryRenames as $entryRename) { - $rows = $rows->map(fn (Row $row) : Row => $row->rename($entryRename->from(), $entryRename->to())); - } - - return $rows; - } -} diff --git a/src/core/etl/src/Flow/ETL/Transformer/RenameEntryTransformer.php b/src/core/etl/src/Flow/ETL/Transformer/RenameEntryTransformer.php new file mode 100644 index 000000000..4c686e42d --- /dev/null +++ b/src/core/etl/src/Flow/ETL/Transformer/RenameEntryTransformer.php @@ -0,0 +1,39 @@ + + */ +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)); + } +} diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/Transformer/RenameEntriesTransformerTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/Transformer/RenameEntryTransformerTest.php similarity index 97% rename from src/core/etl/tests/Flow/ETL/Tests/Unit/Transformer/RenameEntriesTransformerTest.php rename to src/core/etl/tests/Flow/ETL/Tests/Unit/Transformer/RenameEntryTransformerTest.php index fc6062573..1600f249c 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/Transformer/RenameEntriesTransformerTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/Transformer/RenameEntryTransformerTest.php @@ -11,7 +11,7 @@ use Flow\ETL\Rows; use PHPUnit\Framework\TestCase; -final class RenameEntriesTransformerTest extends TestCase +final class RenameEntryTransformerTest extends TestCase { public function test_renaming_entries() : void {