@@ -8,7 +8,7 @@ |
||
8 | 8 | |
9 | 9 | class CheckTypeConditionTest extends TestCase |
10 | 10 | { |
11 | - public function testCanApply(){ |
|
11 | + public function testCanApply() { |
|
12 | 12 | $table = new Table("foo"); |
13 | 13 | $column = new Column("bar", Type::getType(Type::DECIMAL)); |
14 | 14 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ->column("population")->bigInt() |
64 | 64 | ->column("birthrate")->float() |
65 | 65 | ->column("president_id")->references("persons") |
66 | - ->column("population_density")->decimal(10,2) |
|
66 | + ->column("population_density")->decimal(10, 2) |
|
67 | 67 | ->column("summary")->text(); |
68 | 68 | |
69 | 69 | $users->column("country_id")->references("countries"); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | // address.postal_code column is a varchar, so default generated data will be text. Here we want a postal code : |
112 | 112 | $generatorFinderBuilder->addGenerator( |
113 | - new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column){ |
|
113 | + new \DBFaker\Generators\Conditions\CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column) { |
|
114 | 114 | return $table->getName() == "address" && $column->getName() == "postal_code"; |
115 | 115 | }), |
116 | 116 | new SimpleGeneratorFactory("postcode") |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // all columns that end with "_email" or are named exactly "email" should be emails |
120 | 120 | $generatorFinderBuilder->addGenerator( |
121 | - new CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column){ |
|
121 | + new CallBackCondition(function(\Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column) { |
|
122 | 122 | return preg_match("/([(.*_)|_|]|^)email$/", $column->getName()) === 1; |
123 | 123 | }), |
124 | 124 | new SimpleGeneratorFactory("email") |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $faker->setFakeTableRowNumbers($tableRowNumbers); |
147 | 147 | $faker->fakeDB(); |
148 | 148 | |
149 | - foreach ($tableRowNumbers as $tableName => $expectedCount){ |
|
149 | + foreach ($tableRowNumbers as $tableName => $expectedCount) { |
|
150 | 150 | $count = $conn->fetchColumn('SELECT count(*) from ' . $tableName); |
151 | 151 | $this->assertEquals($expectedCount, $count); |
152 | 152 | } |
@@ -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(); |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | } |
166 | 166 | //Other data will be Faked depending of column's type and attributes. FKs to, but their values wil be overridden. |
167 | 167 | else { |
168 | - if (!$column->getNotnull() && $this->nullProbabilityOccured()){ |
|
168 | + if (!$column->getNotnull() && $this->nullProbabilityOccured()) { |
|
169 | 169 | $value = null; |
170 | - }else{ |
|
170 | + }else { |
|
171 | 171 | $generator = $this->getSimpleColumnGenerator($table, $column); |
172 | 172 | $value = $generator(); |
173 | 173 | } |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | private function insertWithoutFksAndUniqueIndexes($data): void |
218 | 218 | { |
219 | 219 | $plateform = $this->connection->getDatabasePlatform(); |
220 | - foreach ($data as $tableName => $rows){ |
|
220 | + foreach ($data as $tableName => $rows) { |
|
221 | 221 | $table = $this->schemaManager->listTableDetails($tableName); |
222 | 222 | |
223 | 223 | //initiate column types for insert : only get the first array to retrieve column names |
224 | 224 | $types = []; |
225 | 225 | $first = reset($rows); |
226 | - if ($first){ |
|
227 | - foreach ($first as $columnName => $value){ |
|
226 | + if ($first) { |
|
227 | + foreach ($first as $columnName => $value) { |
|
228 | 228 | /** @var Column $column */ |
229 | 229 | $column = $table->getColumn($columnName); |
230 | 230 | $types[] = $column->getType()->getBindingType(); |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | |
234 | 234 | //insert faked data |
235 | 235 | $cnt = count($rows); |
236 | - foreach ($rows as $index => $row){ |
|
236 | + foreach ($rows as $index => $row) { |
|
237 | 237 | $dbRow = []; |
238 | - foreach ($row as $columnName => $value){ |
|
238 | + foreach ($row as $columnName => $value) { |
|
239 | 239 | $column = $table->getColumn($columnName); |
240 | 240 | $newVal = $column->getType()->convertToDatabaseValue($value, $plateform); |
241 | 241 | $dbRow[$column->getQuotedName($this->connection->getDatabasePlatform())] = $newVal; |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | $this->connection->insert($table->getName(), $dbRow, $types); |
245 | 245 | } |
246 | 246 | //if autoincrement, add the new ID to the PKRegistry |
247 | - if ($table->hasPrimaryKey()){ |
|
247 | + if ($table->hasPrimaryKey()) { |
|
248 | 248 | $pkColumnName = $table->getPrimaryKeyColumns()[0]; |
249 | 249 | $pkColumn = $table->getColumn($pkColumnName); |
250 | - if ($pkColumn->getAutoincrement() && $this->schemaHelper->isPrimaryKeyColumn($table, $pkColumn)){ |
|
250 | + if ($pkColumn->getAutoincrement() && $this->schemaHelper->isPrimaryKeyColumn($table, $pkColumn)) { |
|
251 | 251 | $this->getPkRegistry($table)->addValue([$pkColumnName => $this->connection->lastInsertId()]); |
252 | 252 | } |
253 | 253 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function getPkRegistry(Table $table, $isSelfReferencing = false) : PrimaryKeyRegistry |
264 | 264 | { |
265 | - $index = $table->getName().($isSelfReferencing ? 'dbfacker_self_referencing' :''); |
|
265 | + $index = $table->getName() . ($isSelfReferencing ? 'dbfacker_self_referencing' : ''); |
|
266 | 266 | if (!isset($this->primaryKeyRegistries[$index])) { |
267 | 267 | $this->primaryKeyRegistries[$index] = new PrimaryKeyRegistry($this->connection, $table, $this->schemaHelper, $isSelfReferencing); |
268 | 268 | } |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | $this->log->info('Step 2.1 : Drop FKs ...'); |
310 | 310 | $foreignKeys = []; |
311 | 311 | $tables = $this->schemaManager->listTables(); |
312 | - foreach ($tables as $table){ |
|
313 | - foreach ($table->getForeignKeys() as $fk){ |
|
312 | + foreach ($tables as $table) { |
|
313 | + foreach ($table->getForeignKeys() as $fk) { |
|
314 | 314 | $foreignTable = $this->schemaManager->listTableDetails($fk->getForeignTableName()); |
315 | - foreach ($fk->getColumns() as $localColumnName){ |
|
315 | + foreach ($fk->getColumns() as $localColumnName) { |
|
316 | 316 | $localColumn = $table->getColumn($localColumnName); |
317 | 317 | $selfReferencing = $fk->getForeignTableName() === $table->getName(); |
318 | 318 | $fkValueGenerator = new ForeignKeyColumnGenerator($table, $localColumn, $this->getPkRegistry($foreignTable, $selfReferencing), $fk, $this->fakerManagerHelper, $this->schemaHelper); |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | private function restoreForeignKeys($foreignKeys) : void |
333 | 333 | { |
334 | 334 | $this->log->info('Step 4 : restore foreign keys'); |
335 | - foreach ($foreignKeys as $tableName => $fks){ |
|
336 | - foreach ($fks as $fk){ |
|
335 | + foreach ($foreignKeys as $tableName => $fks) { |
|
336 | + foreach ($fks as $fk) { |
|
337 | 337 | $this->schemaManager->createForeignKey($fk, $tableName); |
338 | 338 | } |
339 | 339 | } |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | $this->log->info('Step 2.2 : Drop Multiple indexes ...'); |
349 | 349 | $multipleUniqueContraints = []; |
350 | 350 | $tables = $this->schemaManager->listTables(); |
351 | - foreach ($tables as $table){ |
|
352 | - foreach ($table->getIndexes() as $index){ |
|
353 | - if ($index->isUnique() && count($index->getColumns()) > 1){ |
|
351 | + foreach ($tables as $table) { |
|
352 | + foreach ($table->getIndexes() as $index) { |
|
353 | + if ($index->isUnique() && count($index->getColumns()) > 1) { |
|
354 | 354 | $multipleUniqueContraints[$table->getName()][] = $index; |
355 | 355 | $this->schemaManager->dropIndex($index->getQuotedName($this->connection->getDatabasePlatform()), $table->getName()); |
356 | 356 | } |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | private function restoreMultipleUniqueContraints($multipleUniqueContraints): void |
366 | 366 | { |
367 | 367 | $this->log->info('Step 5 : restore multiple unique indexes keys'); |
368 | - foreach ($multipleUniqueContraints as $tableName => $indexes){ |
|
369 | - foreach ($indexes as $index){ |
|
368 | + foreach ($multipleUniqueContraints as $tableName => $indexes) { |
|
369 | + foreach ($indexes as $index) { |
|
370 | 370 | $this->schemaManager->createIndex($index, $tableName); |
371 | 371 | } |
372 | 372 | } |
@@ -384,24 +384,24 @@ discard block |
||
384 | 384 | private function updateMultipleUniqueIndexedColumns($multipleUniqueContraints, $handledFKColumns) : array |
385 | 385 | { |
386 | 386 | |
387 | - foreach ($multipleUniqueContraints as $tableName => $indexes){ |
|
387 | + foreach ($multipleUniqueContraints as $tableName => $indexes) { |
|
388 | 388 | $table = $this->schemaManager->listTableDetails($tableName); |
389 | 389 | |
390 | - foreach ($indexes as $index){ |
|
391 | - foreach ($index->getColumns() as $columnName){ |
|
392 | - $fullColumnName = $tableName. '.' .$columnName; |
|
393 | - if (!\in_array($fullColumnName, $handledFKColumns, true)){ |
|
390 | + foreach ($indexes as $index) { |
|
391 | + foreach ($index->getColumns() as $columnName) { |
|
392 | + $fullColumnName = $tableName . '.' . $columnName; |
|
393 | + if (!\in_array($fullColumnName, $handledFKColumns, true)) { |
|
394 | 394 | $handledFKColumns[] = $fullColumnName; |
395 | 395 | } |
396 | 396 | } |
397 | 397 | } |
398 | 398 | |
399 | - $stmt = $this->connection->query('SELECT * FROM ' .$tableName); |
|
400 | - $count = $this->connection->fetchColumn('SELECT count(*) FROM ' .$tableName); |
|
399 | + $stmt = $this->connection->query('SELECT * FROM ' . $tableName); |
|
400 | + $count = $this->connection->fetchColumn('SELECT count(*) FROM ' . $tableName); |
|
401 | 401 | $i = 1; |
402 | 402 | while ($row = $stmt->fetch()) { |
403 | 403 | $newValues = []; |
404 | - foreach ($indexes as $index){ |
|
404 | + foreach ($indexes as $index) { |
|
405 | 405 | /** @var Index $index */ |
406 | 406 | $compoundColumnGenerator = $this->getCompoundColumnGenerator($table, $index, $count); |
407 | 407 | $newValues = array_merge($newValues, $compoundColumnGenerator()); |
@@ -423,23 +423,23 @@ discard block |
||
423 | 423 | */ |
424 | 424 | private function updateRemainingForeignKeys($foreignKeys, $handledFKColumns): void |
425 | 425 | { |
426 | - foreach ($foreignKeys as $tableName => $fks){ |
|
427 | - if (!array_key_exists($tableName, $this->fakeTableRowNumbers)){ |
|
426 | + foreach ($foreignKeys as $tableName => $fks) { |
|
427 | + if (!array_key_exists($tableName, $this->fakeTableRowNumbers)) { |
|
428 | 428 | //only update tables where data has been inserted |
429 | 429 | continue; |
430 | 430 | } |
431 | 431 | |
432 | 432 | $table = $this->schemaManager->listTableDetails($tableName); |
433 | 433 | |
434 | - $stmt = $this->connection->query('SELECT * FROM ' .$tableName); |
|
435 | - $count = $this->connection->fetchColumn("SELECT count(*) FROM ".$tableName); |
|
434 | + $stmt = $this->connection->query('SELECT * FROM ' . $tableName); |
|
435 | + $count = $this->connection->fetchColumn("SELECT count(*) FROM " . $tableName); |
|
436 | 436 | $i = 1; |
437 | 437 | while ($row = $stmt->fetch()) { |
438 | 438 | $newValues = []; |
439 | 439 | foreach ($fks as $fk) { |
440 | 440 | $localColumns = $fk->getLocalColumns(); |
441 | 441 | foreach ($localColumns as $index => $localColumn) { |
442 | - if (\in_array($tableName . '.' . $localColumn, $handledFKColumns)){ |
|
442 | + if (\in_array($tableName . '.' . $localColumn, $handledFKColumns)) { |
|
443 | 443 | continue; |
444 | 444 | } |
445 | 445 | $column = $table->getColumn($localColumn); |
@@ -448,8 +448,8 @@ discard block |
||
448 | 448 | } |
449 | 449 | } |
450 | 450 | $row = $this->stripUnselectableColumns($table, $row); |
451 | - if (count($newValues) && $this->connection->update($tableName, $newValues, $row) === 0){ |
|
452 | - throw new DBFakerException("Row has not been updated $tableName - ". var_export($newValues,true) . ' - ' . var_export($row, true)); |
|
451 | + if (count($newValues) && $this->connection->update($tableName, $newValues, $row) === 0) { |
|
452 | + throw new DBFakerException("Row has not been updated $tableName - " . var_export($newValues, true) . ' - ' . var_export($row, true)); |
|
453 | 453 | }; |
454 | 454 | $this->log->info("Step 3.3 : updated $i of $count for $tableName"); |
455 | 455 | $i++; |
@@ -468,10 +468,10 @@ discard block |
||
468 | 468 | private function updateExtensionContraints($extensionConstraints) : array |
469 | 469 | { |
470 | 470 | $handledFKColumns = []; |
471 | - foreach ($extensionConstraints as $fk){ |
|
471 | + foreach ($extensionConstraints as $fk) { |
|
472 | 472 | $localTableName = $fk->getLocalTable()->getQuotedName($this->connection->getDatabasePlatform()); |
473 | 473 | $stmt = $this->connection->query('SELECT * FROM ' . $localTableName); |
474 | - $count = $this->connection->fetchColumn('SELECT count(*) FROM ' .$localTableName); |
|
474 | + $count = $this->connection->fetchColumn('SELECT count(*) FROM ' . $localTableName); |
|
475 | 475 | $i = 1; |
476 | 476 | while ($row = $stmt->fetch()) { |
477 | 477 | $newValues = []; |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | $newValues[$localColumn] = $fkValueGenerator(); |
484 | 484 | } |
485 | 485 | $row = $this->stripUnselectableColumns($fk->getLocalTable(), $row); |
486 | - if ($this->connection->update($localTableName, $newValues, $row) === 0){ |
|
487 | - throw new DBFakerException("Row has not been updated $localTableName - ". var_export($newValues,true) . ' - ' . var_export($row, true)); |
|
486 | + if ($this->connection->update($localTableName, $newValues, $row) === 0) { |
|
487 | + throw new DBFakerException("Row has not been updated $localTableName - " . var_export($newValues, true) . ' - ' . var_export($row, true)); |
|
488 | 488 | }; |
489 | 489 | $this->log->info("Updated $i of $count for $localTableName"); |
490 | 490 | $i++; |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | */ |
504 | 504 | private function getCompoundColumnGenerator(Table $table, Index $index, int $count): CompoundColumnGenerator |
505 | 505 | { |
506 | - if (!isset($this->compoundColumnGenerators[$table->getName() . "." . $index->getName()])){ |
|
506 | + if (!isset($this->compoundColumnGenerators[$table->getName() . "." . $index->getName()])) { |
|
507 | 507 | $compoundGenerator = new CompoundColumnGenerator($table, $index, $this->schemaHelper, $this, $this->schemaManager, $this->fakerManagerHelper, $count); |
508 | 508 | $this->compoundColumnGenerators[$table->getName() . '.' . $index->getName()] = $compoundGenerator; |
509 | 509 | } |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | return array_filter($row, function(string $columnName) use ($table) { |
545 | 545 | return !\in_array($table->getColumn($columnName)->getType()->getName(), [ |
546 | 546 | Type::BINARY, Type::JSON, Type::JSON_ARRAY, Type::SIMPLE_ARRAY, Type::TARRAY, Type::BLOB, Type::JSON, Type::OBJECT |
547 | - ],true); |
|
547 | + ], true); |
|
548 | 548 | }, ARRAY_FILTER_USE_KEY); |
549 | 549 | } |
550 | 550 | |
@@ -557,9 +557,9 @@ discard block |
||
557 | 557 | $this->log->info('Step 2.1 : store extension constraints ...'); |
558 | 558 | $extensionConstraints = []; |
559 | 559 | $tables = $this->schemaManager->listTables(); |
560 | - foreach ($tables as $table){ |
|
561 | - foreach ($table->getForeignKeys() as $fk){ |
|
562 | - if ($this->schemaHelper->isExtendingKey($fk)){ |
|
560 | + foreach ($tables as $table) { |
|
561 | + foreach ($table->getForeignKeys() as $fk) { |
|
562 | + if ($this->schemaHelper->isExtendingKey($fk)) { |
|
563 | 563 | $extensionConstraints[] = $fk; |
564 | 564 | } |
565 | 565 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | protected function generateRandomValue(Column $column) |
54 | 54 | { |
55 | - switch ($column->getType()->getName()){ |
|
55 | + switch ($column->getType()->getName()) { |
|
56 | 56 | case Type::BIGINT: |
57 | 57 | return $this->bigRandomNumber(); |
58 | 58 | case Type::INTEGER: |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | case Type::FLOAT: |
63 | 63 | return $this->faker->randomFloat(10, $this->min, $this->max); |
64 | 64 | default: |
65 | - throw new UnsupportedDataTypeException("Cannot generate numeric value for Type : '".$column->getType()->getName()."'"); |
|
65 | + throw new UnsupportedDataTypeException("Cannot generate numeric value for Type : '" . $column->getType()->getName() . "'"); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | private function bigRandomNumber() : string |
73 | 73 | { |
74 | - $difference = bcadd(bcsub($this->max,$this->min),"1"); |
|
74 | + $difference = bcadd(bcsub($this->max, $this->min), "1"); |
|
75 | 75 | $rand_percent = bcdiv((string) mt_rand(), (string) mt_getrandmax(), 8); // 0 - 1.0 |
76 | 76 | return bcadd($this->min, bcmul($difference, $rand_percent, 8), 0); |
77 | 77 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function __construct(string $fakerProperty, bool $generateUniqueValues = false) |
27 | 27 | { |
28 | 28 | $this->faker = Factory::create(); |
29 | - if ($generateUniqueValues){ |
|
29 | + if ($generateUniqueValues) { |
|
30 | 30 | $this->faker->unique(); |
31 | 31 | } |
32 | 32 | $this->fakerProperty = $fakerProperty; |
@@ -18,7 +18,7 @@ |
||
18 | 18 | */ |
19 | 19 | public function __construct(string $globExpression) |
20 | 20 | { |
21 | - $this->globExpression= $globExpression; |
|
21 | + $this->globExpression = $globExpression; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function __construct(Column $column, bool $generateUniqueValues = false) |
28 | 28 | { |
29 | 29 | $this->faker = Factory::create(); |
30 | - if ($generateUniqueValues){ |
|
30 | + if ($generateUniqueValues) { |
|
31 | 31 | $this->faker->unique(); |
32 | 32 | } |
33 | 33 | $this->column = $column; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @throws \Doctrine\DBAL\DBALException |
46 | 46 | * @throws \Doctrine\DBAL\Schema\SchemaException |
47 | 47 | */ |
48 | - public function __construct(Table $table, Column $column, PrimaryKeyRegistry $foreignPkRegistry, ForeignKeyConstraint $fk, DBFakerSchemaManager $schemaManager, SchemaHelper $schemaHelper) |
|
48 | + public function __construct(Table $table, Column $column, PrimaryKeyRegistry $foreignPkRegistry, ForeignKeyConstraint $fk, DBFakerSchemaManager $schemaManager, SchemaHelper $schemaHelper) |
|
49 | 49 | { |
50 | 50 | $this->foreignColumn = $schemaManager->getForeignColumn($table, $column); |
51 | 51 | $this->foreignPkRegistry = $foreignPkRegistry; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | $randomPk = $this->foreignPkRegistry->loadValuesFromTable()->getRandomValue($this->alreadyGeneratedValues); |
63 | 63 | $value = $randomPk[$this->foreignColumn->getName()]; |
64 | - if ($this->generateUniqueValues){ |
|
64 | + if ($this->generateUniqueValues) { |
|
65 | 65 | $this->alreadyGeneratedValues[] = $randomPk; |
66 | 66 | } |
67 | 67 | return $value; |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function __construct(Table $table, Index $index, SchemaHelper $schemaHelper, DBFaker $dbFaker, AbstractSchemaManager $schemaManager, DBFakerSchemaManager $fakerManagerHelper, int $valuesCount) |
42 | 42 | { |
43 | - foreach ($index->getColumns() as $columnName){ |
|
43 | + foreach ($index->getColumns() as $columnName) { |
|
44 | 44 | //FK or normal column ? |
45 | 45 | $column = $table->getColumn($columnName); |
46 | - if ($schemaHelper->isColumnPartOfForeignKeyConstraint($table, $column)){ |
|
46 | + if ($schemaHelper->isColumnPartOfForeignKeyConstraint($table, $column)) { |
|
47 | 47 | $fkConstraint = $schemaHelper->getForeignKeyConstraintByLocal($table, $column); |
48 | - if ($fkConstraint === null){ |
|
48 | + if ($fkConstraint === null) { |
|
49 | 49 | throw new SchemaLogicException($column->getName() . ' was detected as foreign key but could not get it'); |
50 | 50 | } |
51 | 51 | $foreignTableName = $fkConstraint->getForeignTableName(); |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | $foreignTable = $schemaManager->listTableDetails($foreignTableName); |
54 | 54 | $pkRegistry = $dbFaker->getPkRegistry($foreignTable); |
55 | 55 | $values = $pkRegistry->loadValuesFromTable()->getAllValues(); |
56 | - $this->possibleValues[$columnName] = array_map(function ($value) use ($foreignColumn) { |
|
56 | + $this->possibleValues[$columnName] = array_map(function($value) use ($foreignColumn) { |
|
57 | 57 | return $value[$foreignColumn->getName()]; |
58 | 58 | }, $values); |
59 | - }else{ |
|
59 | + }else { |
|
60 | 60 | $generator = $dbFaker->getSimpleColumnGenerator($table, $column); |
61 | - for($i = 0; $i < $valuesCount; $i++) { |
|
61 | + for ($i = 0; $i < $valuesCount; $i++) { |
|
62 | 62 | $this->possibleValues[$columnName][] = $generator(); |
63 | 63 | } |
64 | 64 | } |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | public function __invoke() : array |
71 | 71 | { |
72 | 72 | $returnVal = []; |
73 | - foreach ($this->possibleValues as $columnName => $values){ |
|
73 | + foreach ($this->possibleValues as $columnName => $values) { |
|
74 | 74 | $returnVal[$columnName] = $values[array_rand($values)]; |
75 | 75 | } |
76 | - if (!\in_array($returnVal, $this->generatedValues, true)){ |
|
76 | + if (!\in_array($returnVal, $this->generatedValues, true)) { |
|
77 | 77 | $this->generatedValues[] = $returnVal; |
78 | 78 | return $returnVal; |
79 | 79 | } |