Code Duplication    Length = 24-25 lines in 2 locations

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

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

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

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