Code Duplication    Length = 24-25 lines in 2 locations

src/Phinx/Db/Adapter/MysqlAdapter.php 1 location

@@ 1220-1243 (lines=24) @@
1217
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1218
     * @return string
1219
     */
1220
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1221
    {
1222
        $def = '';
1223
        if ($foreignKey->getConstraint()) {
1224
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1225
        }
1226
        $columnNames = [];
1227
        foreach ($foreignKey->getColumns() as $column) {
1228
            $columnNames[] = $this->quoteColumnName($column);
1229
        }
1230
        $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1231
        $refColumnNames = [];
1232
        foreach ($foreignKey->getReferencedColumns() as $column) {
1233
            $refColumnNames[] = $this->quoteColumnName($column);
1234
        }
1235
        $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1236
        if ($foreignKey->getOnDelete()) {
1237
            $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1238
        }
1239
        if ($foreignKey->getOnUpdate()) {
1240
            $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1241
        }
1242
1243
        return $def;
1244
    }
1245
1246
    /**

src/Phinx/Db/Adapter/SQLiteAdapter.php 1 location

@@ 1251-1275 (lines=25) @@
1248
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1249
     * @return string
1250
     */
1251
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1252
    {
1253
        $def = '';
1254
        if ($foreignKey->getConstraint()) {
1255
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1256
        } else {
1257
            $columnNames = [];
1258
            foreach ($foreignKey->getColumns() as $column) {
1259
                $columnNames[] = $this->quoteColumnName($column);
1260
            }
1261
            $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1262
            $refColumnNames = [];
1263
            foreach ($foreignKey->getReferencedColumns() as $column) {
1264
                $refColumnNames[] = $this->quoteColumnName($column);
1265
            }
1266
            $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1267
            if ($foreignKey->getOnDelete()) {
1268
                $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1269
            }
1270
            if ($foreignKey->getOnUpdate()) {
1271
                $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1272
            }
1273
        }
1274
1275
        return $def;
1276
    }
1277
1278
    /**