@@ -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 | } |
@@ -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 | } |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | public function getForeignKeyConstraintByLocal(Table $table, Column $column) : ?ForeignKeyConstraint |
75 | 75 | { |
76 | 76 | $table = $this->schema->getTable($table->getName()); |
77 | - foreach ($table->getForeignKeys() as $foreignKeyConstraint){ |
|
78 | - if (\in_array($column->getName(), $foreignKeyConstraint->getLocalColumns(), true)){ |
|
77 | + foreach ($table->getForeignKeys() as $foreignKeyConstraint) { |
|
78 | + if (\in_array($column->getName(), $foreignKeyConstraint->getLocalColumns(), true)) { |
|
79 | 79 | return $foreignKeyConstraint; |
80 | 80 | } |
81 | 81 | } |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | public function isForeignKetAlsoUniqueIndex($fk) : bool |
113 | 113 | { |
114 | 114 | $table = $fk->getLocalTable(); |
115 | - foreach ($table->getIndexes() as $index){ |
|
116 | - if ($index->isUnique() && count($index->getColumns()) === count($fk->getLocalColumns())){ |
|
115 | + foreach ($table->getIndexes() as $index) { |
|
116 | + if ($index->isUnique() && count($index->getColumns()) === count($fk->getLocalColumns())) { |
|
117 | 117 | $indexCols = $index->getColumns(); |
118 | 118 | $fkCols = $fk->getColumns(); |
119 | 119 | sort($indexCols); |
120 | 120 | sort($fkCols); |
121 | - if ($indexCols == $fkCols){ |
|
121 | + if ($indexCols == $fkCols) { |
|
122 | 122 | return true; |
123 | 123 | } |
124 | 124 | } |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | $this->connection = $connection; |
50 | 50 | $refTable = null; |
51 | 51 | $refCols = []; |
52 | - foreach ($table->getForeignKeys() as $fk){ |
|
53 | - if ($helper->isExtendingKey($fk) && $table->getName() !== $fk->getForeignTableName()){ |
|
52 | + foreach ($table->getForeignKeys() as $fk) { |
|
53 | + if ($helper->isExtendingKey($fk) && $table->getName() !== $fk->getForeignTableName()) { |
|
54 | 54 | $refTable = $fk->getForeignTableName(); |
55 | 55 | $refCols = $fk->getForeignColumns(); |
56 | 56 | } |
57 | 57 | } |
58 | - if ($isSelfReferencing || !$refTable){ |
|
58 | + if ($isSelfReferencing || !$refTable) { |
|
59 | 59 | $pk = $table->getPrimaryKey(); |
60 | - if ($pk === null){ |
|
60 | + if ($pk === null) { |
|
61 | 61 | throw new SchemaLogicException('No PK on table ' . $table->getName()); |
62 | 62 | } |
63 | 63 | $refTable = $table->getName(); |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function loadValuesFromTable() : PrimaryKeyRegistry |
76 | 76 | { |
77 | - if (!$this->valuesLoaded){ |
|
77 | + if (!$this->valuesLoaded) { |
|
78 | 78 | $this->values = []; |
79 | 79 | $colNames = implode(",", $this->columnNames); |
80 | 80 | $rows = $this->connection->query("SELECT $colNames FROM " . $this->tableName)->fetchAll(); |
81 | - foreach ($rows as $row){ |
|
81 | + foreach ($rows as $row) { |
|
82 | 82 | $pk = []; |
83 | - foreach ($this->columnNames as $column){ |
|
83 | + foreach ($this->columnNames as $column) { |
|
84 | 84 | $pk[$column] = $row[$column]; |
85 | 85 | } |
86 | 86 | $this->values[] = $pk; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | $keys = array_keys($value); |
100 | 100 | sort($keys); |
101 | - if ($this->columnNames != $keys){ |
|
101 | + if ($this->columnNames != $keys) { |
|
102 | 102 | throw new PrimaryKeyColumnMismatchException('PrimaryKeys do not match between PKStore and addValue'); |
103 | 103 | } |
104 | 104 | $this->values[] = $value; |