| Conditions | 3 |
| Paths | 3 |
| Total Lines | 87 |
| Code Lines | 61 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 118 | protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { |
||
| 119 | $schemaDiff = parent::getDiff($targetSchema, $connection); |
||
| 120 | |||
| 121 | // oracle forces us to quote the identifiers |
||
| 122 | $schemaDiff->newTables = array_map(function (Table $table) { |
||
| 123 | return new Table( |
||
| 124 | $this->connection->quoteIdentifier($table->getName()), |
||
| 125 | array_map(function (Column $column) { |
||
| 126 | return $this->quoteColumn($column); |
||
| 127 | }, $table->getColumns()), |
||
| 128 | array_map(function (Index $index) { |
||
| 129 | return $this->quoteIndex($index); |
||
| 130 | }, $table->getIndexes()), |
||
| 131 | [], |
||
| 132 | array_map(function (ForeignKeyConstraint $fck) { |
||
| 133 | return $this->quoteForeignKeyConstraint($fck); |
||
| 134 | }, $table->getForeignKeys()), |
||
| 135 | $table->getOptions() |
||
| 136 | ); |
||
| 137 | }, $schemaDiff->newTables); |
||
| 138 | |||
| 139 | $schemaDiff->removedTables = array_map(function (Table $table) { |
||
| 140 | return new Table( |
||
| 141 | $this->connection->quoteIdentifier($table->getName()), |
||
| 142 | $table->getColumns(), |
||
| 143 | $table->getIndexes(), |
||
| 144 | [], |
||
| 145 | $table->getForeignKeys(), |
||
| 146 | $table->getOptions() |
||
| 147 | ); |
||
| 148 | }, $schemaDiff->removedTables); |
||
| 149 | |||
| 150 | foreach ($schemaDiff->changedTables as $tableDiff) { |
||
| 151 | $tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name); |
||
| 152 | |||
| 153 | $tableDiff->addedColumns = array_map(function (Column $column) { |
||
| 154 | return $this->quoteColumn($column); |
||
| 155 | }, $tableDiff->addedColumns); |
||
| 156 | |||
| 157 | foreach ($tableDiff->changedColumns as $column) { |
||
| 158 | $column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName); |
||
| 159 | // auto increment is not relevant for oracle and can anyhow not be applied on change |
||
| 160 | $column->changedProperties = array_diff($column->changedProperties, ['autoincrement', 'unsigned']); |
||
| 161 | } |
||
| 162 | // remove columns that no longer have changed (because autoincrement and unsigned are not supported) |
||
| 163 | $tableDiff->changedColumns = array_filter($tableDiff->changedColumns, function (ColumnDiff $column) { |
||
| 164 | return count($column->changedProperties) > 0; |
||
| 165 | }); |
||
| 166 | |||
| 167 | $tableDiff->removedColumns = array_map(function (Column $column) { |
||
| 168 | return $this->quoteColumn($column); |
||
| 169 | }, $tableDiff->removedColumns); |
||
| 170 | |||
| 171 | $tableDiff->renamedColumns = array_map(function (Column $column) { |
||
| 172 | return $this->quoteColumn($column); |
||
| 173 | }, $tableDiff->renamedColumns); |
||
| 174 | |||
| 175 | $tableDiff->addedIndexes = array_map(function (Index $index) { |
||
| 176 | return $this->quoteIndex($index); |
||
| 177 | }, $tableDiff->addedIndexes); |
||
| 178 | |||
| 179 | $tableDiff->changedIndexes = array_map(function (Index $index) { |
||
| 180 | return $this->quoteIndex($index); |
||
| 181 | }, $tableDiff->changedIndexes); |
||
| 182 | |||
| 183 | $tableDiff->removedIndexes = array_map(function (Index $index) { |
||
| 184 | return $this->quoteIndex($index); |
||
| 185 | }, $tableDiff->removedIndexes); |
||
| 186 | |||
| 187 | $tableDiff->renamedIndexes = array_map(function (Index $index) { |
||
| 188 | return $this->quoteIndex($index); |
||
| 189 | }, $tableDiff->renamedIndexes); |
||
| 190 | |||
| 191 | $tableDiff->addedForeignKeys = array_map(function (ForeignKeyConstraint $fkc) { |
||
| 192 | return $this->quoteForeignKeyConstraint($fkc); |
||
| 193 | }, $tableDiff->addedForeignKeys); |
||
| 194 | |||
| 195 | $tableDiff->changedForeignKeys = array_map(function (ForeignKeyConstraint $fkc) { |
||
| 196 | return $this->quoteForeignKeyConstraint($fkc); |
||
| 197 | }, $tableDiff->changedForeignKeys); |
||
| 198 | |||
| 199 | $tableDiff->removedForeignKeys = array_map(function (ForeignKeyConstraint $fkc) { |
||
| 200 | return $this->quoteForeignKeyConstraint($fkc); |
||
| 201 | }, $tableDiff->removedForeignKeys); |
||
| 202 | } |
||
| 203 | |||
| 204 | return $schemaDiff; |
||
| 205 | } |
||
| 225 |