Code Duplication    Length = 24-25 lines in 2 locations

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

@@ 1482-1506 (lines=25) @@
1479
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1480
     * @return string
1481
     */
1482
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1483
    {
1484
        $def = '';
1485
        if ($foreignKey->getConstraint()) {
1486
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1487
        } else {
1488
            $columnNames = [];
1489
            foreach ($foreignKey->getColumns() as $column) {
1490
                $columnNames[] = $this->quoteColumnName($column);
1491
            }
1492
            $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1493
            $refColumnNames = [];
1494
            foreach ($foreignKey->getReferencedColumns() as $column) {
1495
                $refColumnNames[] = $this->quoteColumnName($column);
1496
            }
1497
            $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1498
            if ($foreignKey->getOnDelete()) {
1499
                $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1500
            }
1501
            if ($foreignKey->getOnUpdate()) {
1502
                $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1503
            }
1504
        }
1505
1506
        return $def;
1507
    }
1508
1509
    /**

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

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