@@ -19,7 +19,7 @@ |
||
| 19 | 19 | public function __construct(bool $generateUniqueValues = false) |
| 20 | 20 | { |
| 21 | 21 | $this->faker = Factory::create(); |
| 22 | - if ($generateUniqueValues){ |
|
| 22 | + if ($generateUniqueValues) { |
|
| 23 | 23 | $this->faker->unique(); |
| 24 | 24 | } |
| 25 | 25 | } |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $object = $this->generateRandomValue($this->column); |
| 43 | 43 | $iterations = 1; |
| 44 | - while (!$this->isUnique($object)){ |
|
| 44 | + while (!$this->isUnique($object)) { |
|
| 45 | 45 | $object = $this->generateRandomValue($this->column); |
| 46 | 46 | $iterations++; |
| 47 | - if ($iterations > DBFaker::MAX_ITERATIONS_FOR_UNIQUE_VALUE){ |
|
| 47 | + if ($iterations > DBFaker::MAX_ITERATIONS_FOR_UNIQUE_VALUE) { |
|
| 48 | 48 | throw new MaxNbOfIterationsForUniqueValueException('Unable to generate a unique value in less then maximumn allowed iterations.'); |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | private function storeObjectInGeneratedValues($object) : void |
| 66 | 66 | { |
| 67 | - if ($this->generateUniqueValues){ |
|
| 67 | + if ($this->generateUniqueValues) { |
|
| 68 | 68 | $this->generatedValues[] = $object; |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | private function isUnique($object) : bool |
| 77 | 77 | { |
| 78 | - if (!$this->generateUniqueValues){ |
|
| 78 | + if (!$this->generateUniqueValues) { |
|
| 79 | 79 | return true; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -38,14 +38,14 @@ |
||
| 38 | 38 | public function findGenerator(Table $table, Column $column, SchemaHelper $helper) : FakeDataGeneratorInterface |
| 39 | 39 | { |
| 40 | 40 | $generator = null; |
| 41 | - if (!isset($this->generators[$table->getName() . '.' . $column->getName()])){ |
|
| 42 | - foreach ($this->generatorFactories as list($condition, $generatorFactory)){ |
|
| 41 | + if (!isset($this->generators[$table->getName() . '.' . $column->getName()])) { |
|
| 42 | + foreach ($this->generatorFactories as list($condition, $generatorFactory)) { |
|
| 43 | 43 | /** @var $condition ConditionInterface */ |
| 44 | - if ($condition->canApply($table, $column)){ |
|
| 44 | + if ($condition->canApply($table, $column)) { |
|
| 45 | 45 | $generator = $generatorFactory->create($table, $column, $helper); |
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | - if (!$generator){ |
|
| 48 | + if (!$generator) { |
|
| 49 | 49 | throw new UnsupportedDataTypeException('Could not find suitable generator for column ' . $table->getName() . '.' . $column->getName() . ' of type : ' . $column->getType()->getName()); |
| 50 | 50 | } |
| 51 | 51 | $this->generators[$table->getName() . '.' . $column->getName()] = $generator; |
@@ -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; |
@@ -45,27 +45,27 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | public function getForeignColumn(Table $table, Column $column) : Column |
| 47 | 47 | { |
| 48 | - if (isset($this->foreignKeyMappings[$table->getName()][$column->getName()])){ |
|
| 48 | + if (isset($this->foreignKeyMappings[$table->getName()][$column->getName()])) { |
|
| 49 | 49 | return $this->foreignKeyMappings[$table->getName()][$column->getName()]["column"]; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $lookupColumn = null; |
| 53 | 53 | $foreignKeys = $table->getForeignKeys(); |
| 54 | - foreach ($foreignKeys as $foreignKeyConstraint){ |
|
| 54 | + foreach ($foreignKeys as $foreignKeyConstraint) { |
|
| 55 | 55 | $localColumns = $foreignKeyConstraint->getLocalColumns(); |
| 56 | 56 | $foreignColumns = $foreignKeyConstraint->getForeignColumns(); |
| 57 | 57 | $foreignTable = $this->schemaManager->listTableDetails($foreignKeyConstraint->getForeignTableName()); |
| 58 | - foreach ($localColumns as $index => $localColumn){ |
|
| 58 | + foreach ($localColumns as $index => $localColumn) { |
|
| 59 | 59 | $foreignColumn = $foreignColumns[$index]; |
| 60 | 60 | $this->foreignKeyMappings[$table->getName()][$localColumn] = ["table" => $foreignTable, "column" => $foreignTable->getColumn($foreignColumn)]; |
| 61 | - if ($localColumn === $column->getName()){ |
|
| 61 | + if ($localColumn === $column->getName()) { |
|
| 62 | 62 | $lookupColumn = $foreignTable->getColumn($foreignColumn); |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if (!$lookupColumn){ |
|
| 68 | - throw new SchemaLogicException("Could not find foreign column for local column '".$table->getName().".".$column->getName()."'"); |
|
| 67 | + if (!$lookupColumn) { |
|
| 68 | + throw new SchemaLogicException("Could not find foreign column for local column '" . $table->getName() . "." . $column->getName() . "'"); |
|
| 69 | 69 | } |
| 70 | 70 | return $lookupColumn; |
| 71 | 71 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | public function __construct(bool $generateUniqueValues = false) |
| 20 | 20 | { |
| 21 | 21 | $this->faker = Factory::create(); |
| 22 | - if ($generateUniqueValues){ |
|
| 22 | + if ($generateUniqueValues) { |
|
| 23 | 23 | $this->faker->unique(); |
| 24 | 24 | } |
| 25 | 25 | } |
@@ -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 | } |
@@ -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) { |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | throw FileTooLargeException::create($file, $this->column); |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | - if (\count($files) === 0){ |
|
| 43 | - throw new NoTestFilesFoundException("No files found for glob expression '".$this->globExpression."'"); |
|
| 42 | + if (\count($files) === 0) { |
|
| 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)]; |
@@ -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 | } |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | public function isForeignKeyAlsoUniqueIndex(ForeignKeyConstraint $fk) : bool |
| 109 | 109 | { |
| 110 | 110 | $table = $fk->getLocalTable(); |
| 111 | - foreach ($table->getIndexes() as $index){ |
|
| 112 | - if ($index->isUnique() && count($index->getColumns()) === count($fk->getLocalColumns())){ |
|
| 111 | + foreach ($table->getIndexes() as $index) { |
|
| 112 | + if ($index->isUnique() && count($index->getColumns()) === count($fk->getLocalColumns())) { |
|
| 113 | 113 | $indexCols = $index->getColumns(); |
| 114 | 114 | $fkCols = $fk->getColumns(); |
| 115 | 115 | sort($indexCols); |
| 116 | 116 | sort($fkCols); |
| 117 | - if ($indexCols == $fkCols){ |
|
| 117 | + if ($indexCols == $fkCols) { |
|
| 118 | 118 | return true; |
| 119 | 119 | } |
| 120 | 120 | } |