Code Duplication    Length = 24-25 lines in 2 locations

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

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

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

@@ 1085-1108 (lines=24) @@
1082
     * @param \Phinx\Db\Table\ForeignKey $foreignKey
1083
     * @return string
1084
     */
1085
    protected function getForeignKeySqlDefinition(ForeignKey $foreignKey)
1086
    {
1087
        $def = '';
1088
        if ($foreignKey->getConstraint()) {
1089
            $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint());
1090
        }
1091
        $columnNames = [];
1092
        foreach ($foreignKey->getColumns() as $column) {
1093
            $columnNames[] = $this->quoteColumnName($column);
1094
        }
1095
        $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')';
1096
        $refColumnNames = [];
1097
        foreach ($foreignKey->getReferencedColumns() as $column) {
1098
            $refColumnNames[] = $this->quoteColumnName($column);
1099
        }
1100
        $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')';
1101
        if ($foreignKey->getOnDelete()) {
1102
            $def .= ' ON DELETE ' . $foreignKey->getOnDelete();
1103
        }
1104
        if ($foreignKey->getOnUpdate()) {
1105
            $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate();
1106
        }
1107
1108
        return $def;
1109
    }
1110
1111
    /**