Code Duplication    Length = 5-5 lines in 3 locations

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

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

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

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