| Conditions | 17 |
| Paths | 240 |
| Total Lines | 62 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 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 |
||
| 132 | protected function _toSql(AbstractPlatform $platform, $saveMode = false) |
||
| 133 | { |
||
| 134 | // Disable renaming of indices |
||
| 135 | $this->disableIndicesRenaming(); |
||
| 136 | |||
| 137 | $sql = array(); |
||
| 138 | |||
| 139 | if ($platform->supportsSchemas()) { |
||
| 140 | foreach ($this->newNamespaces as $newNamespace) { |
||
| 141 | $sql[] = $platform->getCreateSchemaSQL($newNamespace); |
||
| 142 | } |
||
| 143 | } |
||
| 144 | |||
| 145 | if ($platform->supportsForeignKeyConstraints() && $saveMode == false) { |
||
|
|
|||
| 146 | foreach ($this->orphanedForeignKeys as $orphanedForeignKey) { |
||
| 147 | $sql[] = $platform->getDropForeignKeySQL($orphanedForeignKey, $orphanedForeignKey->getLocalTableName()); |
||
| 148 | } |
||
| 149 | } |
||
| 150 | |||
| 151 | if ($platform->supportsSequences() == true) { |
||
| 152 | foreach ($this->changedSequences as $sequence) { |
||
| 153 | $sql[] = $platform->getAlterSequenceSQL($sequence); |
||
| 154 | } |
||
| 155 | |||
| 156 | if ($saveMode === false) { |
||
| 157 | foreach ($this->removedSequences as $sequence) { |
||
| 158 | $sql[] = $platform->getDropSequenceSQL($sequence); |
||
| 159 | } |
||
| 160 | } |
||
| 161 | |||
| 162 | foreach ($this->newSequences as $sequence) { |
||
| 163 | $sql[] = $platform->getCreateSequenceSQL($sequence); |
||
| 164 | } |
||
| 165 | } |
||
| 166 | |||
| 167 | $foreignKeySql = array(); |
||
| 168 | foreach ($this->newTables as $table) { |
||
| 169 | $sql = array_merge( |
||
| 170 | $sql, |
||
| 171 | $platform->getCreateTableSQL($table, AbstractPlatform::CREATE_INDEXES) |
||
| 172 | ); |
||
| 173 | |||
| 174 | if ($platform->supportsForeignKeyConstraints()) { |
||
| 175 | foreach ($table->getForeignKeys() as $foreignKey) { |
||
| 176 | $foreignKeySql[] = $platform->getCreateForeignKeySQL($foreignKey, $table); |
||
| 177 | } |
||
| 178 | } |
||
| 179 | } |
||
| 180 | $sql = array_merge($sql, $foreignKeySql); |
||
| 181 | |||
| 182 | if ($saveMode === false) { |
||
| 183 | foreach ($this->removedTables as $table) { |
||
| 184 | $sql[] = $platform->getDropTableSQL($table); |
||
| 185 | } |
||
| 186 | } |
||
| 187 | |||
| 188 | foreach ($this->changedTables as $tableDiff) { |
||
| 189 | $sql = array_merge($sql, $platform->getAlterTableSQL($tableDiff)); |
||
| 190 | } |
||
| 191 | |||
| 192 | return $sql; |
||
| 193 | } |
||
| 194 | |||
| 202 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.