Code Duplication    Length = 24-25 lines in 2 locations

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

@@ 1059-1083 (lines=25) @@
1056
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1057
     * @return string
1058
     */
1059
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1060
    {
1061
        $def = '';
1062
        if ($foreignKey->getConstraint()) {
1063
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1064
        } else {
1065
            $columnNames = [];
1066
            foreach ($foreignKey->getColumns() as $column) {
1067
                $columnNames[] = $this->quoteColumnName($column);
1068
            }
1069
            $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1070
            $refColumnNames = [];
1071
            foreach ($foreignKey->getReferencedColumns() as $column) {
1072
                $refColumnNames[] = $this->quoteColumnName($column);
1073
            }
1074
            $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1075
            if ($foreignKey->getOnDelete()) {
1076
                $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1077
            }
1078
            if ($foreignKey->getOnUpdate()) {
1079
                $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1080
            }
1081
        }
1082
1083
        return $def;
1084
    }
1085
}
1086

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

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