Code Duplication    Length = 24-25 lines in 2 locations

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

@@ 1070-1093 (lines=24) @@
1067
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1068
     * @return string
1069
     */
1070
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1071
    {
1072
        $def = '';
1073
        if ($foreignKey->getConstraint()) {
1074
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1075
        }
1076
        $columnNames = [];
1077
        foreach ($foreignKey->getColumns() as $column) {
1078
            $columnNames[] = $this->quoteColumnName($column);
1079
        }
1080
        $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1081
        $refColumnNames = [];
1082
        foreach ($foreignKey->getReferencedColumns() as $column) {
1083
            $refColumnNames[] = $this->quoteColumnName($column);
1084
        }
1085
        $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1086
        if ($foreignKey->getOnDelete()) {
1087
            $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1088
        }
1089
        if ($foreignKey->getOnUpdate()) {
1090
            $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1091
        }
1092
1093
        return $def;
1094
    }
1095
1096
    /**

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

@@ 1073-1097 (lines=25) @@
1070
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1071
     * @return string
1072
     */
1073
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1074
    {
1075
        $def = '';
1076
        if ($foreignKey->getConstraint()) {
1077
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1078
        } else {
1079
            $columnNames = [];
1080
            foreach ($foreignKey->getColumns() as $column) {
1081
                $columnNames[] = $this->quoteColumnName($column);
1082
            }
1083
            $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1084
            $refColumnNames = [];
1085
            foreach ($foreignKey->getReferencedColumns() as $column) {
1086
                $refColumnNames[] = $this->quoteColumnName($column);
1087
            }
1088
            $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1089
            if ($foreignKey->getOnDelete()) {
1090
                $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1091
            }
1092
            if ($foreignKey->getOnUpdate()) {
1093
                $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1094
            }
1095
        }
1096
1097
        return $def;
1098
    }
1099
1100
    /**