Completed
Push — master ( 4966ad...2cf3a8 )
by Derek Stephen
02:07
created

DbCredentials   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 122
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 80.56%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 17
c 3
b 0
f 0
lcom 1
cbo 0
dl 0
loc 122
ccs 29
cts 36
cp 0.8056
rs 10

13 Methods

Rating   Name   Duplication   Size   Complexity  
A getPassword() 0 4 1
A getUser() 0 4 1
A getDatabase() 0 4 1
A getDriver() 0 4 1
A toArray() 0 4 1
B __construct() 0 8 5
A setPassword() 0 5 1
A setUser() 0 5 1
A setDatabase() 0 5 1
A setDriver() 0 5 1
A addToContainer() 0 5 1
A getEntityPath() 0 4 1
A hasEntityPath() 0 4 1
1
<?php
2
3
4
namespace Del\Common\Config;
5
6
use Del\Common\Container\RegistrationInterface;
7
use Pimple\Container;
8
9
class DbCredentials implements RegistrationInterface
10
{
11
    /** @var  array */
12
    private $credentials;
13
    
14 6
    public function __construct(array $array = null)
15
    {
16 6
        $this->credentials = [];
17 6
        $this->credentials['driver'] = $array['driver'] ?: 'pdo_mysql';
18 6
        $this->credentials['dbname'] = $array['dbname'] ?: 'delboy1978uk';
19 6
        $this->credentials['user'] = $array['user'] ?: 'dbuser';
20 6
        $this->credentials['password'] = $array['password'] ?: '[123456]';
21 6
    }
22
23
    /**
24
     * @return string
25
     */
26 1
    public function getPassword()
27
    {
28 1
        return $this->credentials['password'];
29
    }
30
31
    /**
32
     * @param string $password
33
     * @return DbCredentials
34
     */
35 1
    public function setPassword($password)
36
    {
37 1
        $this->credentials['password'] = $password;
38 1
        return $this;
39
    }
40
41
    /**
42
     * @return string
43
     */
44 1
    public function getUser()
45
    {
46 1
        return $this->credentials['user'];
47
    }
48
49
    /**
50
     * @param string $user
51
     * @return DbCredentials
52
     */
53 2
    public function setUser($user)
54
    {
55 2
        $this->credentials['user'] = $user;
56 2
        return $this;
57
    }
58
59
    /**
60
     * @return string
61
     */
62 1
    public function getDatabase()
63
    {
64 1
        return $this->credentials['dbname'];
65
    }
66
67
    /**
68
     * @param string $database
69
     * @return DbCredentials
70
     */
71 1
    public function setDatabase($database)
72
    {
73 1
        $this->credentials['dbname'] = $database;
74 1
        return $this;
75
    }
76
77
    /**
78
     * @return string
79
     */
80 1
    public function getDriver()
81
    {
82 1
        return $this->credentials['driver'];
83
    }
84
85
    /**
86
     * @param string $driver
87
     * @return DbCredentials
88
     */
89 1
    public function setDriver($driver)
90
    {
91 1
        $this->credentials['driver'] = $driver;
92 1
        return $this;
93
    }
94
95
    /**
96
     * @return array
97
     */
98 5
    public function toArray()
99
    {
100 5
        return $this->credentials;
101
    }
102
103
    /**
104
     * @param Container $c
105
     * @return Container
106
     */
107
    public function addToContainer(Container $c)
108
    {
109
        $c['db.credentials'] = $this->toArray();
110
        return $c;
111
    }
112
113
    /**
114
     * @return null
115
     */
116
    function getEntityPath()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
117
    {
118
        return null;
119
    }
120
121
    /**
122
     * @return bool
123
     */
124
    function hasEntityPath()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
125
    {
126
        return false;
127
    }
128
129
130
}