From e1746aa54b0de25481e18e433041afbd3d9a0273 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Fri, 20 Oct 2023 18:07:15 +0200 Subject: [PATCH] Remove dead `ArrayRowsFactory` class --- .../Flow/ETL/Row/Factory/ArrayRowsFactory.php | 66 ------------------- .../Unit/Row/Factory/ArrayRowsFactoryTest.php | 29 -------- 2 files changed, 95 deletions(-) delete mode 100644 src/core/etl/src/Flow/ETL/Row/Factory/ArrayRowsFactory.php delete mode 100644 src/core/etl/tests/Flow/ETL/Tests/Unit/Row/Factory/ArrayRowsFactoryTest.php diff --git a/src/core/etl/src/Flow/ETL/Row/Factory/ArrayRowsFactory.php b/src/core/etl/src/Flow/ETL/Row/Factory/ArrayRowsFactory.php deleted file mode 100644 index 881356724..000000000 --- a/src/core/etl/src/Flow/ETL/Row/Factory/ArrayRowsFactory.php +++ /dev/null @@ -1,66 +0,0 @@ - - */ -final class ArrayRowsFactory implements RowsFactory -{ - public function __construct( - private readonly Row\EntryFactory $entryFactory = new NativeEntryFactory() - ) { - } - - public function __serialize() : array - { - return [ - 'entry_factory' => $this->entryFactory, - ]; - } - - public function __unserialize(array $data) : void - { - $this->entryFactory = $data['entry_factory']; - } - - /** - * @param array> $data - * - * @throws InvalidArgumentException - * @throws \Flow\ETL\Exception\RuntimeException - */ - public function create(array $data) : Rows - { - foreach ($data as $row) { - /** @psalm-suppress DocblockTypeContradiction */ - if (!\is_array($row)) { - throw new InvalidArgumentException('ArrayRowsFactory expects data to be an array of arrays'); - } - } - - $rows = new Rows(); - - foreach ($data as $dataRow) { - $entries = []; - - /** - * @var mixed $value - */ - foreach ($dataRow as $entry => $value) { - $entries[] = $this->entryFactory->create((string) $entry, $value); - } - - $rows = $rows->add(Row::create(...$entries)); - } - - return $rows; - } -} diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/Row/Factory/ArrayRowsFactoryTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/Row/Factory/ArrayRowsFactoryTest.php deleted file mode 100644 index b55966ae3..000000000 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/Row/Factory/ArrayRowsFactoryTest.php +++ /dev/null @@ -1,29 +0,0 @@ -create($data = [['id' => 1], ['id' => 2], ['id' => 3]]); - - $this->assertSame($data, $rows->toArray()); - } - - public function test_creating_rows_from_flat_array() : void - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('ArrayRowsFactory expects data to be an array of arrays'); - - (new ArrayRowsFactory())->create([1, 2, 3]); - } -}