Code Duplication    Length = 24-25 lines in 2 locations

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

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

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

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