@@ -15,7 +15,7 @@ |
||
| 15 | 15 | { |
| 16 | 16 | $column = new Column('foo', Type::getType(Type::BINARY)); |
| 17 | 17 | $column->setLength(255); |
| 18 | - $blobGenerator = new BlobGenerator(__DIR__.'/../fixtures/blob/*.png', $column); |
|
| 18 | + $blobGenerator = new BlobGenerator(__DIR__ . '/../fixtures/blob/*.png', $column); |
|
| 19 | 19 | $this->expectException(FileTooLargeException::class); |
| 20 | 20 | $blobGenerator->__invoke(); |
| 21 | 21 | } |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if (!$lookupColumn) { |
| 67 | - throw new SchemaLogicException("Could not find foreign column for local column '".$table->getName().".".$column->getName()."'"); |
|
| 67 | + throw new SchemaLogicException("Could not find foreign column for local column '" . $table->getName() . "." . $column->getName() . "'"); |
|
| 68 | 68 | } |
| 69 | 69 | return $lookupColumn; |
| 70 | 70 | } |
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | */ |
| 111 | 111 | public function getRandomValue(array $excludedValues) : array |
| 112 | 112 | { |
| 113 | - $values = array_filter($this->values, function ($value) use ($excludedValues) { |
|
| 113 | + $values = array_filter($this->values, function($value) use ($excludedValues) { |
|
| 114 | 114 | return !\in_array($value, $excludedValues, true); |
| 115 | 115 | }); |
| 116 | 116 | return $values[array_rand($values, 1)]; |
@@ -52,10 +52,10 @@ |
||
| 52 | 52 | $foreignTable = $schemaManager->listTableDetails($foreignTableName); |
| 53 | 53 | $pkRegistry = $dbFaker->getPkRegistry($foreignTable); |
| 54 | 54 | $values = $pkRegistry->loadValuesFromTable()->getAllValues(); |
| 55 | - $this->possibleValues[$columnName] = array_map(function ($value) use ($foreignColumn) { |
|
| 55 | + $this->possibleValues[$columnName] = array_map(function($value) use ($foreignColumn) { |
|
| 56 | 56 | return $value[$foreignColumn->getName()]; |
| 57 | 57 | }, $values); |
| 58 | - } else { |
|
| 58 | + }else { |
|
| 59 | 59 | $generator = $dbFaker->getSimpleColumnGenerator($table, $column); |
| 60 | 60 | for ($i = 0; $i < $valuesCount; $i++) { |
| 61 | 61 | $this->possibleValues[$columnName][] = $generator(); |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | return true; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $filtered = array_filter($this->generatedValues, function ($value) use ($object) { |
|
| 82 | + $filtered = array_filter($this->generatedValues, function($value) use ($object) { |
|
| 83 | 83 | return $object === $value; |
| 84 | 84 | }); |
| 85 | 85 | return count($filtered) === 0; |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | case Type::FLOAT: |
| 62 | 62 | return $this->faker->randomFloat(10, $this->min, $this->max); |
| 63 | 63 | default: |
| 64 | - throw new UnsupportedDataTypeException("Cannot generate numeric value for Type : '".$column->getType()->getName()."'"); |
|
| 64 | + throw new UnsupportedDataTypeException("Cannot generate numeric value for Type : '" . $column->getType()->getName() . "'"); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | public function __invoke() |
| 31 | 31 | { |
| 32 | 32 | $files = glob($this->globExpression, GLOB_MARK); |
| 33 | - $files = array_filter($files, function ($fileName) { |
|
| 33 | + $files = array_filter($files, function($fileName) { |
|
| 34 | 34 | return strrpos($fileName, DIRECTORY_SEPARATOR) !== \strlen($fileName) - 1; |
| 35 | 35 | }); |
| 36 | 36 | foreach ($files as $file) { |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | if (\count($files) === 0) { |
| 43 | - throw new NoTestFilesFoundException("No files found for glob expression '".$this->globExpression."'"); |
|
| 43 | + throw new NoTestFilesFoundException("No files found for glob expression '" . $this->globExpression . "'"); |
|
| 44 | 44 | } |
| 45 | 45 | $files = array_values($files); |
| 46 | 46 | $chosenFile = $files[random_int(0, \count($files) - 1)]; |
@@ -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); |