Code Duplication    Length = 24-25 lines in 2 locations

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

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

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

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