Code Duplication    Length = 24-25 lines in 2 locations

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

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

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

@@ 1465-1489 (lines=25) @@
1462
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1463
     * @return string
1464
     */
1465
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1466
    {
1467
        $def = '';
1468
        if ($foreignKey->getConstraint()) {
1469
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1470
        } else {
1471
            $columnNames = [];
1472
            foreach ($foreignKey->getColumns() as $column) {
1473
                $columnNames[] = $this->quoteColumnName($column);
1474
            }
1475
            $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1476
            $refColumnNames = [];
1477
            foreach ($foreignKey->getReferencedColumns() as $column) {
1478
                $refColumnNames[] = $this->quoteColumnName($column);
1479
            }
1480
            $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1481
            if ($foreignKey->getOnDelete()) {
1482
                $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1483
            }
1484
            if ($foreignKey->getOnUpdate()) {
1485
                $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1486
            }
1487
        }
1488
1489
        return $def;
1490
    }
1491
1492
    /**