Code Duplication    Length = 24-25 lines in 2 locations

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

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

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

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