DbCredentials   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 131
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 0
dl 0
loc 131
ccs 37
cts 37
cp 1
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPassword() 0 4 1
A setPassword() 0 4 1
A getUser() 0 4 1
A setUser() 0 4 1
A getDatabase() 0 4 1
A setDatabase() 0 4 1
A getHost() 0 4 1
A setHost() 0 4 1
A getDriver() 0 4 1
A setDriver() 0 4 1
A toArray() 0 4 1
A addToContainer() 0 5 1
A getEntityPath() 0 4 1
A hasEntityPath() 0 4 1
1
<?php
2
3
namespace Del\Common\Config;
4
5
use Barnacle\RegistrationInterface;
6
use Barnacle\Container;
7
8
class DbCredentials implements RegistrationInterface
9
{
10
    /** @var  array */
11
    private $credentials = [
12
        'driver' => 'pdo_mysql',
13
        'host' => '127.0.0.1',
14
        'dbname' => '',
15
        'user' => '',
16
        'password' => '',
17
    ];
18
    
19 11
    public function __construct(array $array = [])
20
    {
21 11
        $this->credentials = array_merge($this->credentials, $array);
22 11
    }
23
24
    /**
25
     * @return string
26
     */
27 1
    public function getPassword(): string
28
    {
29 1
        return $this->credentials['password'];
30
    }
31
32
    /**
33
     * @param string $password
34
     */
35 11
    public function setPassword(string $password)
36
    {
37 11
        $this->credentials['password'] = $password;
38 11
    }
39
40
    /**
41
     * @return string
42
     */
43 1
    public function getUser(): string
44
    {
45 1
        return $this->credentials['user'];
46
    }
47
48
    /**
49
     * @param string $user
50
     * @return DbCredentials
51
     */
52 12
    public function setUser(string $user)
53
    {
54 12
        $this->credentials['user'] = $user;
55 12
    }
56
57
    /**
58
     * @return string
59
     */
60 1
    public function getDatabase(): string
61
    {
62 1
        return $this->credentials['dbname'];
63
    }
64
65
    /**
66
     * @param string $database
67
     */
68 11
    public function setDatabase(string $database)
69
    {
70 11
        $this->credentials['dbname'] = $database;
71 11
    }
72
73
    /**
74
     * @return string
75
     */
76 1
    public function getHost(): string
77
    {
78 1
        return $this->credentials['host'];
79
    }
80
81
    /**
82
     * @param string $database
0 ignored issues
show
Bug introduced by
There is no parameter named $database. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
83
     */
84 10
    public function setHost(string $host)
85
    {
86 10
        $this->credentials['host'] = $host;
87 10
    }
88
89
    /**
90
     * @return string
91
     */
92 1
    public function getDriver(): string
93
    {
94 1
        return $this->credentials['driver'];
95
    }
96
97
    /**
98
     * @param string $driver
99
     */
100 11
    public function setDriver(string $driver)
101
    {
102 11
        $this->credentials['driver'] = $driver;
103 11
    }
104
105
    /**
106
     * @return array
107
     */
108 9
    public function toArray(): array
109
    {
110 9
        return $this->credentials;
111
    }
112
113
    /**
114
     * @param Container $c
115
     * @return Container
116
     */
117 1
    public function addToContainer(Container $c): Container
118
    {
119 1
        $c['db.credentials'] = $this->toArray();
120 1
        return $c;
121
    }
122
123
    /**
124
     * @return string
125
     */
126 1
    public function getEntityPath(): string
127
    {
128 1
        return '';
129
    }
130
131
    /**
132
     * @return bool
133
     */
134 1
    public function hasEntityPath(): bool
135
    {
136 1
        return false;
137
    }
138
}
139