Passed
Push — master ( c3008a...16aa80 )
by Jean Paul
02:00
created

getConnectionParameters()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
c 0
b 0
f 0
nc 3
nop 0
dl 0
loc 18
rs 9.9
1
<?php
2
3
namespace Coco\SourceWatcher\Core\Database\Connections;
4
5
/**
6
 * Class ClientServerDatabaseConnector
7
 *
8
 * @package Coco\SourceWatcher\Core\Database\Connections
9
 */
10
abstract class ClientServerDatabaseConnector extends Connector
11
{
12
    protected string $host;
13
14
    protected int $port;
15
16
    protected string $dbName;
17
18
    public function getHost () : string
19
    {
20
        return $this->host;
21
    }
22
23
    public function setHost ( string $host ) : void
24
    {
25
        $this->host = $host;
26
    }
27
28
    public function getPort () : int
29
    {
30
        return $this->port;
31
    }
32
33
    public function setPort ( int $port ) : void
34
    {
35
        $this->port = $port;
36
    }
37
38
    public function getDbName () : string
39
    {
40
        return $this->dbName;
41
    }
42
43
    public function setDbName ( string $dbName ) : void
44
    {
45
        $this->dbName = $dbName;
46
    }
47
48
    protected array $extraParameters;
49
50
    public function getConnectionParameters () : array
51
    {
52
        $this->connectionParameters = [];
53
54
        $this->connectionParameters["driver"] = $this->driver;
55
        $this->connectionParameters["user"] = $this->user;
56
        $this->connectionParameters["password"] = $this->password;
57
        $this->connectionParameters["host"] = $this->host;
58
        $this->connectionParameters["port"] = $this->port;
59
        $this->connectionParameters["dbname"] = $this->dbName;
60
61
        foreach ( $this->extraParameters as $parameterName => $localVariable ) {
62
            if ( isset( $localVariable ) && $localVariable !== "" ) {
63
                $this->connectionParameters[$parameterName] = $localVariable;
64
            }
65
        }
66
67
        return $this->connectionParameters;
68
    }
69
}
70