Code Duplication    Length = 24-25 lines in 2 locations

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

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

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

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