Code Duplication    Length = 18-18 lines in 2 locations

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

@@ 324-341 (lines=18) @@
321
        }
322
323
        // Add the primary key(s)
324
        if (isset($newOptions['primary_key']) && $newOptions['primary_key'] !== false) {
325
            $sql = sprintf(
326
                'ADD CONSTRAINT %s PRIMARY KEY (',
327
                $this->quoteColumnName($parts['table'] . '_pkey')
328
            );
329
            if (is_string($newOptions['primary_key'])) { // handle primary_key => 'id'
330
                $sql .= $this->quoteColumnName($newOptions['primary_key']);
331
            } elseif (is_array($newOptions['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id')
332
                $sql .= implode(',', array_map([$this, 'quoteColumnName'], $newOptions['primary_key']));
333
            } else {
334
                throw new \InvalidArgumentException(sprintf(
335
                    "Invalid value for option 'primary_key': %s",
336
                    json_encode($newOptions['primary_key'])
337
                ));
338
            }
339
            $sql .= ')';
340
            $instructions->addAlter($sql);
341
        }
342
343
        // Process table comments
344
        if (array_key_exists('comment', $newOptions)) {

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

@@ 326-343 (lines=18) @@
323
        }
324
325
        // Add the primary key(s)
326
        if (isset($newOptions['primary_key']) && $newOptions['primary_key'] !== false) {
327
            $sql = sprintf(
328
                'ADD CONSTRAINT %s PRIMARY KEY (',
329
                $this->quoteColumnName('PK_' . $table->getName())
330
            );
331
            if (is_string($newOptions['primary_key'])) { // handle primary_key => 'id'
332
                $sql .= $this->quoteColumnName($newOptions['primary_key']);
333
            } elseif (is_array($newOptions['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id')
334
                $sql .= implode(',', array_map([$this, 'quoteColumnName'], $newOptions['primary_key']));
335
            } else {
336
                throw new \InvalidArgumentException(sprintf(
337
                    "Invalid value for option 'primary_key': %s",
338
                    json_encode($newOptions['primary_key'])
339
                ));
340
            }
341
            $sql .= ')';
342
            $instructions->addAlter($sql);
343
        }
344
345
        return $instructions;
346
    }