Code Duplication    Length = 24-25 lines in 2 locations

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

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

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

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