Total Complexity | 5 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | trait ConfigTrait |
||
10 | { |
||
11 | /** |
||
12 | * Get the full path to the database directory |
||
13 | * |
||
14 | * @param array $options |
||
15 | * |
||
16 | * @return string |
||
17 | */ |
||
18 | private function directory(array $options): string |
||
19 | { |
||
20 | return rtrim(str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $options['directory']), '/\\'); |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Get the full path to the database file |
||
25 | * |
||
26 | * @param string $database |
||
27 | * @param array $options |
||
28 | * |
||
29 | * @return string |
||
30 | */ |
||
31 | private function filename(string $database, array $options): string |
||
32 | { |
||
33 | if (!$database) { |
||
34 | // By default, connect to the in memory database. |
||
35 | return ':memory:'; |
||
36 | } |
||
37 | return $this->directory($options) . DIRECTORY_SEPARATOR . $database; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Check if a database file exists |
||
42 | * |
||
43 | * @param string $database |
||
44 | * @param array $options |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | private function fileExists(string $database, array $options): bool |
||
51 | } |
||
52 | } |
||
53 |