Code Duplication    Length = 24-25 lines in 2 locations

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

@@ 1197-1220 (lines=24) @@
1194
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1195
     * @return string
1196
     */
1197
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1198
    {
1199
        $def = '';
1200
        if ($foreignKey->getConstraint()) {
1201
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1202
        }
1203
        $columnNames = [];
1204
        foreach ($foreignKey->getColumns() as $column) {
1205
            $columnNames[] = $this->quoteColumnName($column);
1206
        }
1207
        $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1208
        $refColumnNames = [];
1209
        foreach ($foreignKey->getReferencedColumns() as $column) {
1210
            $refColumnNames[] = $this->quoteColumnName($column);
1211
        }
1212
        $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1213
        if ($foreignKey->getOnDelete()) {
1214
            $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1215
        }
1216
        if ($foreignKey->getOnUpdate()) {
1217
            $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1218
        }
1219
1220
        return $def;
1221
    }
1222
1223
    /**

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

@@ 1234-1258 (lines=25) @@
1231
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1232
     * @return string
1233
     */
1234
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1235
    {
1236
        $def = '';
1237
        if ($foreignKey->getConstraint()) {
1238
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1239
        } else {
1240
            $columnNames = [];
1241
            foreach ($foreignKey->getColumns() as $column) {
1242
                $columnNames[] = $this->quoteColumnName($column);
1243
            }
1244
            $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1245
            $refColumnNames = [];
1246
            foreach ($foreignKey->getReferencedColumns() as $column) {
1247
                $refColumnNames[] = $this->quoteColumnName($column);
1248
            }
1249
            $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1250
            if ($foreignKey->getOnDelete()) {
1251
                $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1252
            }
1253
            if ($foreignKey->getOnUpdate()) {
1254
                $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1255
            }
1256
        }
1257
1258
        return $def;
1259
    }
1260
1261
    /**