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

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