1 | <?php |
||
29 | class DbSettings implements ArrayAccess, IteratorAggregate |
||
30 | { |
||
31 | /** |
||
32 | * @var string|null known field members |
||
33 | */ |
||
34 | private $tablePrefix, $host, $port, $unixSocket, $dbName, $username, $password; |
||
|
|||
35 | |||
36 | /** |
||
37 | * @var array field array |
||
38 | */ |
||
39 | private $config; |
||
40 | |||
41 | /** |
||
42 | * @param string $file path to app/etc/local.xml |
||
43 | */ |
||
44 | public function __construct($file) |
||
48 | |||
49 | /** |
||
50 | * @param string $file path to app/etc/local.xml |
||
51 | * |
||
52 | * @throws InvalidArgumentException if the file is invalid |
||
53 | */ |
||
54 | public function setFile($file) |
||
83 | |||
84 | /** |
||
85 | * helper method to parse config file segment related to the database settings |
||
86 | * |
||
87 | * @param SimpleXMLElement $resources |
||
88 | */ |
||
89 | private function parseResources(SimpleXMLElement $resources) |
||
130 | |||
131 | /** |
||
132 | * Get Mysql PDO DSN |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | public function getDsn() |
||
160 | |||
161 | /** |
||
162 | * Connects to the database without initializing magento |
||
163 | * |
||
164 | * @throws RuntimeException if pdo_mysql extension is not installed |
||
165 | * @return PDO |
||
166 | */ |
||
167 | public function getConnection() |
||
198 | |||
199 | public function getMysqlClientToolConnectionString() |
||
220 | |||
221 | /** |
||
222 | * Mysql quoting of an identifier |
||
223 | * |
||
224 | * @param string $identifier UTF-8 encoded |
||
225 | * |
||
226 | * @return string quoted identifier |
||
227 | */ |
||
228 | private function quoteIdentifier($identifier) |
||
246 | |||
247 | /** |
||
248 | * @return bool |
||
249 | */ |
||
250 | public function isSocketConnect() |
||
254 | |||
255 | /** |
||
256 | * @return string table prefix, null if not in the settings (no or empty prefix) |
||
257 | */ |
||
258 | public function getTablePrefix() |
||
262 | |||
263 | /** |
||
264 | * @return string hostname, null if there is no hostname setup (e.g. unix_socket) |
||
265 | */ |
||
266 | public function getHost() |
||
270 | |||
271 | /** |
||
272 | * @return string port, null if not setup |
||
273 | */ |
||
274 | public function getPort() |
||
278 | |||
279 | /** |
||
280 | * @return string username |
||
281 | */ |
||
282 | public function getUsername() |
||
286 | |||
287 | /** |
||
288 | * @return string password |
||
289 | */ |
||
290 | public function getPassword() |
||
294 | |||
295 | /** |
||
296 | * @return string unix socket, null if not in use |
||
297 | */ |
||
298 | public function getUnixSocket() |
||
302 | |||
303 | /** |
||
304 | * content of previous $dbSettings field of the DatabaseHelper |
||
305 | * |
||
306 | * @return array |
||
307 | */ |
||
308 | public function getConfig() |
||
312 | |||
313 | /** |
||
314 | * @return string of the database identifier, null if not in use |
||
315 | */ |
||
316 | public function getDatabaseName() |
||
320 | |||
321 | /* |
||
322 | * ArrayAccess interface |
||
323 | */ |
||
324 | |||
325 | /** |
||
326 | * @return boolean true on success or false on failure. |
||
327 | */ |
||
328 | public function offsetExists($offset) |
||
332 | |||
333 | /** |
||
334 | * @return mixed Can return all value types. |
||
335 | */ |
||
336 | public function offsetGet($offset) |
||
344 | |||
345 | /** |
||
346 | * @param mixed $offset |
||
347 | * @param mixed $value |
||
348 | * |
||
349 | * @throws BadMethodCallException |
||
350 | */ |
||
351 | public function offsetSet($offset, $value) |
||
355 | |||
356 | /** |
||
357 | * @param mixed $offset |
||
358 | * |
||
359 | * @throws BadMethodCallException |
||
360 | */ |
||
361 | public function offsetUnset($offset) |
||
365 | |||
366 | /* |
||
367 | * IteratorAggregate |
||
368 | */ |
||
369 | |||
370 | /** |
||
371 | * @return ArrayIterator |
||
372 | */ |
||
373 | public function getIterator() |
||
377 | } |
||
378 |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.