1 | <?php |
||
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() |
|
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() |
|
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() |
|
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() |
|
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() |
|
102 | |||
103 | /** |
||
104 | * @param Container $c |
||
105 | * @return Container |
||
106 | */ |
||
107 | public function addToContainer(Container $c) |
||
112 | |||
113 | /** |
||
114 | * @return null |
||
115 | */ |
||
116 | function getEntityPath() |
||
120 | |||
121 | /** |
||
122 | * @return bool |
||
123 | */ |
||
124 | function hasEntityPath() |
||
128 | |||
129 | |||
130 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.