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

@@ 1292-1316 (lines=25) @@
1289
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1290
     * @return string
1291
     */
1292
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1293
    {
1294
        $def = '';
1295
        if ($foreignKey->getConstraint()) {
1296
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1297
        } else {
1298
            $columnNames = [];
1299
            foreach ($foreignKey->getColumns() as $column) {
1300
                $columnNames[] = $this->quoteColumnName($column);
1301
            }
1302
            $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1303
            $refColumnNames = [];
1304
            foreach ($foreignKey->getReferencedColumns() as $column) {
1305
                $refColumnNames[] = $this->quoteColumnName($column);
1306
            }
1307
            $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1308
            if ($foreignKey->getOnDelete()) {
1309
                $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1310
            }
1311
            if ($foreignKey->getOnUpdate()) {
1312
                $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1313
            }
1314
        }
1315
1316
        return $def;
1317
    }
1318
1319
    /**