Code Duplication    Length = 5-5 lines in 3 locations

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

@@ 64-68 (lines=5) @@
61
            $options = $this->getOptions();
62
63
            // if port is specified use it, otherwise use the PostgreSQL default
64
            if (isset($options['port'])) {
65
                $dsn = 'pgsql:host=' . $options['host'] . ';port=' . $options['port'] . ';dbname=' . $options['name'];
66
            } else {
67
                $dsn = 'pgsql:host=' . $options['host'] . ';dbname=' . $options['name'];
68
            }
69
70
            try {
71
                $db = new \PDO($dsn, $options['user'], $options['pass'], [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]);

src/Phinx/Db/Adapter/SqlServerAdapter.php 2 locations

@@ 65-69 (lines=5) @@
62
            $options = $this->getOptions();
63
64
            // if port is specified use it, otherwise use the SqlServer default
65
            if (empty($options['port'])) {
66
                $dsn = 'sqlsrv:server=' . $options['host'] . ';database=' . $options['name'];
67
            } else {
68
                $dsn = 'sqlsrv:server=' . $options['host'] . ',' . $options['port'] . ';database=' . $options['name'];
69
            }
70
            $dsn .= ';MultipleActiveResultSets=false';
71
72
            $driverOptions = [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION];
@@ 118-122 (lines=5) @@
115
        $options = $this->getOptions();
116
117
        // if port is specified use it, otherwise use the SqlServer default
118
        if (empty($options['port'])) {
119
            $dsn = 'dblib:host=' . $options['host'] . ';dbname=' . $options['name'];
120
        } else {
121
            $dsn = 'dblib:host=' . $options['host'] . ':' . $options['port'] . ';dbname=' . $options['name'];
122
        }
123
124
        $driverOptions = [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION];
125