Code Duplication    Length = 24-25 lines in 2 locations

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

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

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

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