1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Configuration\Database |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/techdivision/import-configuration-jms |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Configuration\Jms\Configuration; |
22
|
|
|
|
23
|
|
|
use JMS\Serializer\Annotation\Type; |
24
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
25
|
|
|
use TechDivision\Import\Configuration\DatabaseConfigurationInterface; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The database configuration. |
29
|
|
|
* |
30
|
|
|
* @author Tim Wagner <[email protected]> |
31
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
32
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
33
|
|
|
* @link https://github.com/techdivision/import-configuration-jms |
34
|
|
|
* @link http://www.techdivision.com |
35
|
|
|
*/ |
36
|
|
|
class Database implements DatabaseConfigurationInterface |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The database identifier for this database connection. |
41
|
|
|
* |
42
|
|
|
* @var string |
43
|
|
|
* @Type("string") |
44
|
|
|
* @SerializedName("id") |
45
|
|
|
*/ |
46
|
|
|
protected $id; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* The PDO DSN to use. |
50
|
|
|
* |
51
|
|
|
* @var string |
52
|
|
|
* @Type("string") |
53
|
|
|
* @SerializedName("pdo-dsn") |
54
|
|
|
*/ |
55
|
|
|
protected $dsn; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* The database host to use. |
59
|
|
|
* |
60
|
|
|
* @var string |
61
|
|
|
* @Type("string") |
62
|
|
|
*/ |
63
|
|
|
protected $host; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* The database port to use. |
67
|
|
|
* |
68
|
|
|
* @var string |
69
|
|
|
* @Type("integer") |
70
|
|
|
*/ |
71
|
|
|
protected $port; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* The DB username to use. |
75
|
|
|
* |
76
|
|
|
* @var string |
77
|
|
|
* @Type("string") |
78
|
|
|
*/ |
79
|
|
|
protected $username; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* The DB password to use. |
83
|
|
|
* |
84
|
|
|
* @var string |
85
|
|
|
* @Type("string") |
86
|
|
|
*/ |
87
|
|
|
protected $password; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* The flag to signal the default datasource or not. |
91
|
|
|
* |
92
|
|
|
* @var boolean |
93
|
|
|
* @Type("boolean") |
94
|
|
|
* @SerializedName("default") |
95
|
|
|
*/ |
96
|
|
|
protected $default = false; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* The DB timeout to use. |
100
|
|
|
* |
101
|
|
|
* @var integer |
102
|
|
|
* @Type("integer") |
103
|
|
|
*/ |
104
|
|
|
protected $timeout; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* The DB version to use. |
108
|
|
|
* |
109
|
|
|
* @var string |
110
|
|
|
* @Type("string") |
111
|
|
|
*/ |
112
|
|
|
protected $version; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* The DB name to use. |
116
|
|
|
* |
117
|
|
|
* @var string |
118
|
|
|
* @Type("string") |
119
|
|
|
*/ |
120
|
|
|
protected $name; |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Set's the database identifier for this database connection. |
124
|
|
|
* |
125
|
|
|
* @param string $id The database identifier |
126
|
|
|
* |
127
|
|
|
* @return void |
128
|
|
|
*/ |
129
|
|
|
public function setId($id) |
130
|
|
|
{ |
131
|
|
|
$this->id = $id; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Return's the database identifier for this database connection. |
136
|
|
|
* |
137
|
|
|
* @return string The database identifier |
138
|
|
|
*/ |
139
|
|
|
public function getId() |
140
|
|
|
{ |
141
|
|
|
return $this->id; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Set's the PDO DSN to use. |
146
|
|
|
* |
147
|
|
|
* @param string $dsn The PDO DSN |
148
|
|
|
* |
149
|
|
|
* @return void |
150
|
|
|
*/ |
151
|
|
|
public function setDsn($dsn) |
152
|
|
|
{ |
153
|
|
|
$this->dsn = $dsn; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Return's the PDO DSN to use. |
158
|
|
|
* |
159
|
|
|
* @return string The PDO DSN |
160
|
|
|
*/ |
161
|
|
|
public function getDsn() |
162
|
|
|
{ |
163
|
|
|
return $this->dsn; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Set's the DB username to use. |
168
|
|
|
* |
169
|
|
|
* @param string $username The DB username |
170
|
|
|
* |
171
|
|
|
* @return void |
172
|
|
|
*/ |
173
|
|
|
public function setUsername($username) |
174
|
|
|
{ |
175
|
|
|
$this->username = $username; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Return's the DB username to use. |
180
|
|
|
* |
181
|
|
|
* @return string The DB username |
182
|
|
|
*/ |
183
|
|
|
public function getUsername() |
184
|
|
|
{ |
185
|
|
|
return $this->username; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* Set's the DB password to use. |
190
|
|
|
* |
191
|
|
|
* @param string $password The DB password |
192
|
|
|
* |
193
|
|
|
* @return void |
194
|
|
|
*/ |
195
|
|
|
public function setPassword($password) |
196
|
|
|
{ |
197
|
|
|
$this->password = $password; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Return's the DB password to use. |
202
|
|
|
* |
203
|
|
|
* @return string The DB password |
204
|
|
|
*/ |
205
|
|
|
public function getPassword() |
206
|
|
|
{ |
207
|
|
|
return $this->password; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* Set's the flag to signal that this is the default datasource or not. |
212
|
|
|
* |
213
|
|
|
* @param boolean $default TRUE if this is the default datasource, else FALSE |
214
|
|
|
* |
215
|
|
|
* @return void |
216
|
|
|
*/ |
217
|
|
|
public function setDefault($default) |
218
|
|
|
{ |
219
|
|
|
$this->default = $default; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* Return's the flag to signal that this is the default datasource or not. |
224
|
|
|
* |
225
|
|
|
* @return boolean TRUE if this is the default datasource, else FALSE |
226
|
|
|
*/ |
227
|
|
|
public function isDefault() |
228
|
|
|
{ |
229
|
|
|
return $this->default; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* Return's the DB name to use. |
234
|
|
|
* |
235
|
|
|
* @return string The DB name |
236
|
|
|
*/ |
237
|
|
|
public function getName() |
238
|
|
|
{ |
239
|
|
|
return $this->name; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* Return's the DB timeout to use. |
244
|
|
|
* |
245
|
|
|
* @return integer The DB timeout |
246
|
|
|
*/ |
247
|
|
|
public function getTimeout() |
248
|
|
|
{ |
249
|
|
|
return $this->timeout; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* Return's the DB version to use. |
254
|
|
|
* |
255
|
|
|
* @return string The DB version |
256
|
|
|
*/ |
257
|
|
|
public function getVersion() |
258
|
|
|
{ |
259
|
|
|
return $this->version; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Return's the DB host to use. |
264
|
|
|
* |
265
|
|
|
* @return string The DB host |
266
|
|
|
*/ |
267
|
|
|
public function getHost() |
268
|
|
|
{ |
269
|
|
|
return $this->host; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* Return's the DB port to use. |
274
|
|
|
* |
275
|
|
|
* @return integer The DB port |
276
|
|
|
*/ |
277
|
|
|
public function getPort() |
278
|
|
|
{ |
279
|
|
|
return $this->port; |
280
|
|
|
} |
281
|
|
|
} |
282
|
|
|
|