Code Duplication    Length = 24-25 lines in 2 locations

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

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

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

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