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

@@ 1436-1460 (lines=25) @@
1433
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1434
     * @return string
1435
     */
1436
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1437
    {
1438
        $def = '';
1439
        if ($foreignKey->getConstraint()) {
1440
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1441
        } else {
1442
            $columnNames = [];
1443
            foreach ($foreignKey->getColumns() as $column) {
1444
                $columnNames[] = $this->quoteColumnName($column);
1445
            }
1446
            $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1447
            $refColumnNames = [];
1448
            foreach ($foreignKey->getReferencedColumns() as $column) {
1449
                $refColumnNames[] = $this->quoteColumnName($column);
1450
            }
1451
            $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1452
            if ($foreignKey->getOnDelete()) {
1453
                $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1454
            }
1455
            if ($foreignKey->getOnUpdate()) {
1456
                $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1457
            }
1458
        }
1459
1460
        return $def;
1461
    }
1462
1463
    /**