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

ClientServerDatabaseConnector   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 58
rs 10
wmc 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getHost() 0 3 1
A setPort() 0 3 1
A getDbName() 0 3 1
A getConnectionParameters() 0 18 4
A getPort() 0 3 1
A setHost() 0 3 1
A setDbName() 0 3 1
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