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-cli-simple |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Cli\Configuration; |
22
|
|
|
|
23
|
|
|
use JMS\Serializer\Annotation\Type; |
24
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
25
|
|
|
use TechDivision\Import\Configuration\DatabaseInterface; |
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-cli-simple |
34
|
|
|
* @link http://www.techdivision.com |
35
|
|
|
*/ |
36
|
|
|
class Database implements DatabaseInterface |
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 DB username to use. |
59
|
|
|
* |
60
|
|
|
* @var string |
61
|
|
|
* @Type("string") |
62
|
|
|
*/ |
63
|
|
|
protected $username; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* The DB password to use. |
67
|
|
|
* |
68
|
|
|
* @var string |
69
|
|
|
* @Type("string") |
70
|
|
|
*/ |
71
|
|
|
protected $password; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* The flag to signal the default datasource or not. |
75
|
|
|
* |
76
|
|
|
* @var boolean |
77
|
|
|
* @Type("boolean") |
78
|
|
|
* @SerializedName("default") |
79
|
|
|
*/ |
80
|
|
|
protected $default = false; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Set's the database identifier for this database connection. |
84
|
|
|
* |
85
|
|
|
* @param string $id The database identifier |
86
|
|
|
* |
87
|
|
|
* @return void |
88
|
|
|
*/ |
89
|
|
|
public function setId($id) |
90
|
|
|
{ |
91
|
|
|
$this->id = $id; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Return's the database identifier for this database connection. |
96
|
|
|
* |
97
|
|
|
* @return string The database identifier |
98
|
|
|
*/ |
99
|
|
|
public function getId() |
100
|
|
|
{ |
101
|
|
|
return $this->id; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Set's the PDO DSN to use. |
106
|
|
|
* |
107
|
|
|
* @param string $dsn The PDO DSN |
108
|
|
|
* |
109
|
|
|
* @return void |
110
|
|
|
*/ |
111
|
|
|
public function setDsn($dsn) |
112
|
|
|
{ |
113
|
|
|
$this->dsn = $dsn; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Return's the PDO DSN to use. |
118
|
|
|
* |
119
|
|
|
* @return string The PDO DSN |
120
|
|
|
*/ |
121
|
|
|
public function getDsn() |
122
|
|
|
{ |
123
|
|
|
return $this->dsn; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Set's the DB username to use. |
128
|
|
|
* |
129
|
|
|
* @param string $username The DB username |
130
|
|
|
* |
131
|
|
|
* @return void |
132
|
|
|
*/ |
133
|
|
|
public function setUsername($username) |
134
|
|
|
{ |
135
|
|
|
$this->username = $username; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Return's the DB username to use. |
140
|
|
|
* |
141
|
|
|
* @return string The DB username |
142
|
|
|
*/ |
143
|
|
|
public function getUsername() |
144
|
|
|
{ |
145
|
|
|
return $this->username; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Set's the DB password to use. |
150
|
|
|
* |
151
|
|
|
* @param string $password The DB password |
152
|
|
|
* |
153
|
|
|
* @return void |
154
|
|
|
*/ |
155
|
|
|
public function setPassword($password) |
156
|
|
|
{ |
157
|
|
|
$this->password = $password; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Return's the DB password to use. |
162
|
|
|
* |
163
|
|
|
* @return string The DB password |
164
|
|
|
*/ |
165
|
|
|
public function getPassword() |
166
|
|
|
{ |
167
|
|
|
return $this->password; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Set's the flag to signal that this is the default datasource or not. |
172
|
|
|
* |
173
|
|
|
* @param boolean $default TRUE if this is the default datasource, else FALSE |
174
|
|
|
* |
175
|
|
|
* @return void |
176
|
|
|
*/ |
177
|
|
|
public function setDefault($default) |
178
|
|
|
{ |
179
|
|
|
$this->default = $default; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Return's the flag to signal that this is the default datasource or not. |
184
|
|
|
* |
185
|
|
|
* @return boolean TRUE if this is the default datasource, else FALSE |
186
|
|
|
*/ |
187
|
|
|
public function isDefault() |
188
|
|
|
{ |
189
|
|
|
return $this->default; |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
|