@@ -64,7 +64,7 @@ |
||
64 | 64 | if ($goDeeper) { |
65 | 65 | $hasGoneDeeper = true; |
66 | 66 | $value = $this->generateRandomObject($depth - 1); |
67 | - } else { |
|
67 | + }else { |
|
68 | 68 | $value = $this->randomValue(); |
69 | 69 | } |
70 | 70 | $obj->$propName = $value; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function fakeDB() : void |
114 | 114 | { |
115 | - set_time_limit(0);//Import may take a looooooong time :) |
|
115 | + set_time_limit(0); //Import may take a looooooong time :) |
|
116 | 116 | $data = $this->generateFakeData(); |
117 | 117 | $extensionContraints = $this->getExtensionConstraints(); |
118 | 118 | $foreignKeys = $this->dropForeignKeys(); |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | //IF column is a PK and Autoincrement then values will be set to null, let the database generate them |
163 | 163 | if ($this->schemaHelper->isPrimaryKeyColumn($table, $column) && $column->getAutoincrement()) { |
164 | 164 | $value = null; |
165 | - } else { |
|
165 | + }else { |
|
166 | 166 | //Other data will be Faked depending of column's type and attributes. FKs to, but their values wil be overridden. |
167 | 167 | if (!$column->getNotnull() && $this->nullProbabilityOccured()) { |
168 | 168 | $value = null; |
169 | - } else { |
|
169 | + }else { |
|
170 | 170 | $generator = $this->getSimpleColumnGenerator($table, $column); |
171 | 171 | $value = $generator(); |
172 | 172 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function getPkRegistry(Table $table, bool $isSelfReferencing = false) : PrimaryKeyRegistry |
266 | 266 | { |
267 | - $index = $table->getName().($isSelfReferencing ? 'dbfacker_self_referencing' :''); |
|
267 | + $index = $table->getName() . ($isSelfReferencing ? 'dbfacker_self_referencing' : ''); |
|
268 | 268 | if (!isset($this->primaryKeyRegistries[$index])) { |
269 | 269 | $this->primaryKeyRegistries[$index] = new PrimaryKeyRegistry($this->connection, $table, $this->schemaHelper, $isSelfReferencing); |
270 | 270 | } |
@@ -391,15 +391,15 @@ discard block |
||
391 | 391 | |
392 | 392 | foreach ($indexes as $index) { |
393 | 393 | foreach ($index->getColumns() as $columnName) { |
394 | - $fullColumnName = $tableName. '.' .$columnName; |
|
394 | + $fullColumnName = $tableName . '.' . $columnName; |
|
395 | 395 | if (!\in_array($fullColumnName, $handledFKColumns, true)) { |
396 | 396 | $handledFKColumns[] = $fullColumnName; |
397 | 397 | } |
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
401 | - $stmt = $this->connection->query('SELECT * FROM ' .$tableName); |
|
402 | - $count = $this->connection->fetchColumn('SELECT count(*) FROM ' .$tableName); |
|
401 | + $stmt = $this->connection->query('SELECT * FROM ' . $tableName); |
|
402 | + $count = $this->connection->fetchColumn('SELECT count(*) FROM ' . $tableName); |
|
403 | 403 | $i = 1; |
404 | 404 | while ($row = $stmt->fetch()) { |
405 | 405 | $newValues = []; |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | |
434 | 434 | $table = $this->schemaManager->listTableDetails($tableName); |
435 | 435 | |
436 | - $stmt = $this->connection->query('SELECT * FROM ' .$tableName); |
|
437 | - $count = $this->connection->fetchColumn("SELECT count(*) FROM ".$tableName); |
|
436 | + $stmt = $this->connection->query('SELECT * FROM ' . $tableName); |
|
437 | + $count = $this->connection->fetchColumn("SELECT count(*) FROM " . $tableName); |
|
438 | 438 | $i = 1; |
439 | 439 | while ($row = $stmt->fetch()) { |
440 | 440 | $newValues = []; |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | } |
452 | 452 | $row = $this->stripUnselectableColumns($table, $row); |
453 | 453 | if (count($newValues) && $this->connection->update($tableName, $newValues, $row) === 0) { |
454 | - throw new DBFakerException("Row has not been updated $tableName - ". var_export($newValues, true) . ' - ' . var_export($row, true)); |
|
454 | + throw new DBFakerException("Row has not been updated $tableName - " . var_export($newValues, true) . ' - ' . var_export($row, true)); |
|
455 | 455 | }; |
456 | 456 | $this->log->info("Step 3.3 : updated $i of $count for $tableName"); |
457 | 457 | $i++; |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | foreach ($extensionConstraints as $fk) { |
474 | 474 | $localTableName = $fk->getLocalTable()->getQuotedName($this->connection->getDatabasePlatform()); |
475 | 475 | $stmt = $this->connection->query('SELECT * FROM ' . $localTableName); |
476 | - $count = $this->connection->fetchColumn('SELECT count(*) FROM ' .$localTableName); |
|
476 | + $count = $this->connection->fetchColumn('SELECT count(*) FROM ' . $localTableName); |
|
477 | 477 | $i = 1; |
478 | 478 | while ($row = $stmt->fetch()) { |
479 | 479 | $newValues = []; |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | } |
487 | 487 | $row = $this->stripUnselectableColumns($fk->getLocalTable(), $row); |
488 | 488 | if ($this->connection->update($localTableName, $newValues, $row) === 0) { |
489 | - throw new DBFakerException("Row has not been updated $localTableName - ". var_export($newValues, true) . ' - ' . var_export($row, true)); |
|
489 | + throw new DBFakerException("Row has not been updated $localTableName - " . var_export($newValues, true) . ' - ' . var_export($row, true)); |
|
490 | 490 | }; |
491 | 491 | $this->log->info("Updated $i of $count for $localTableName"); |
492 | 492 | $i++; |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | */ |
544 | 544 | private function stripUnselectableColumns(Table $table, array $row) : array |
545 | 545 | { |
546 | - return array_filter($row, function (string $columnName) use ($table) { |
|
546 | + return array_filter($row, function(string $columnName) use ($table) { |
|
547 | 547 | return !\in_array($table->getColumn($columnName)->getType()->getName(), [ |
548 | 548 | Type::BINARY, Type::JSON, Type::JSON_ARRAY, Type::SIMPLE_ARRAY, Type::TARRAY, Type::BLOB, Type::JSON, Type::OBJECT |
549 | 549 | ], true); |