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

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