Passed
Push — master ( a506e2...902f0a )
by Joao
05:33 queued 11s
created

PostgresDatabaseTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 28
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 19 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
use ByJG\DbMigration\Database\PgsqlDatabase;
4
use ByJG\DbMigration\Migration;
5
use ByJG\Util\Uri;
6
7
require_once 'BaseDatabase.php';
8
9
10
/**
11
 * @requires extension pdo_pgsql
12
 */
13
class PostgresDatabaseTest extends BaseDatabase
14
{
15
    /**
16
     * @var Migration
17
     */
18
    protected $migrate = null;
19
20
    public function setUp()
21
    {
22
        $host = getenv('PSQL_TEST_HOST');
23
        if (empty($host)) {
24
            $host = "127.0.0.1";
25
        }
26
        $password = getenv('PSQL_PASSWORD');
27
        if (empty($password)) {
28
            $password = 'password';
29
        }
30
        if ($password == '.') {
31
            $password = "";
32
        }
33
34
        $uri = "pgsql://postgres:${password}@${host}/migratedatabase";
35
36
        $this->migrate = new Migration(new Uri($uri), __DIR__ . '/../example/postgres', true, $this->migrationTable);
37
        $this->migrate->registerDatabase("pgsql", PgsqlDatabase::class);
38
        parent::setUp();
39
    }
40
}
41