From bac501c2281d2b0ad4aa170cd7f34811993f485d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tjitse=20Efd=C3=A9?= Date: Thu, 29 Apr 2021 17:59:59 +0200 Subject: [PATCH] Fix array to string conversion --- src/Elgentos/Masquerade/Console/RunCommand.php | 11 ++++++----- .../DataProcessor/DefaultDataProcessorFactory.php | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Elgentos/Masquerade/Console/RunCommand.php b/src/Elgentos/Masquerade/Console/RunCommand.php index 0a59fab..f793505 100644 --- a/src/Elgentos/Masquerade/Console/RunCommand.php +++ b/src/Elgentos/Masquerade/Console/RunCommand.php @@ -168,10 +168,11 @@ private function fakeData(array $table) : void /** @var DataProcessorFactory $dataProcessorFactory */ $dataProcessorFactory = new $dataProcessorFactoryClass(); + $tableName = $table['name']; try { $dataProcessor = $dataProcessorFactory->create($this->output, $this->tableServiceFactory, $table); } catch (TableDoesNotExistsException $exception) { - $this->output->info('Table %s does not exists. Skipping...', $table['name']); + $this->output->info('Table %s does not exists. Skipping...', $tableName); return; } @@ -189,14 +190,14 @@ private function fakeData(array $table) : void $isTruncate = $table['provider']['truncate'] ?? false; if ($isIntegrityImportant && $isDelete) { - $this->output->info('Deleting records from %s table', $table); + $this->output->info('Deleting records from %s table', $tableName); $dataProcessor->delete(); - $this->output->success('Records have been deleted from %s table', $table); + $this->output->success('Records have been deleted from %s table', $tableName); return; } elseif ($isDelete || $isTruncate) { - $this->output->info('Truncating records from %s table', $table); + $this->output->info('Truncating records from %s table', $tableName); $dataProcessor->truncate(); - $this->output->success('Records have been truncated from %s table', $table); + $this->output->success('Records have been truncated from %s table', $tableName); return; } diff --git a/src/Elgentos/Masquerade/DataProcessor/DefaultDataProcessorFactory.php b/src/Elgentos/Masquerade/DataProcessor/DefaultDataProcessorFactory.php index 55395c8..2327000 100644 --- a/src/Elgentos/Masquerade/DataProcessor/DefaultDataProcessorFactory.php +++ b/src/Elgentos/Masquerade/DataProcessor/DefaultDataProcessorFactory.php @@ -24,7 +24,8 @@ public function create( $whereCondition = $tableConfiguration['where'] ?? ''; - foreach ($tableConfiguration['columns'] as $column => $columnData) { + $columns = $tableConfiguration['columns'] ?? []; + foreach ($columns as $column => $columnData) { if ($columnData['nullColumnBeforeRun'] ?? false) { if (strpos($whereCondition, $column) !== false) { $output->warning(