PluginProbe
Disk Usage Insights / 1.7
Disk Usage Insights v1.7
trunk 1.0 1.10 1.11 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
← All changes | src/Domain/DatabaseRepository.php +5 -3 1.31.7 View file →
@@ -5,11 +5,13 @@
5 5 use Mgleis\PhpSqliteJobQueue\Queue;
6 6
7 7 class DatabaseRepository {
8 8
9 + private const OUTPUT_DIR = __DIR__ . '/../../output';
10 +
9 11 public function listDatabases(): array {
10 12
11 - $dir = realpath(__DIR__ . '/../../output');
13 + $dir = realpath(self::OUTPUT_DIR);
12 14 $pattern = $dir . '/*.db';
13 15 $files = glob($pattern);
14 16 rsort($files);
15 17 $results = [];
@@ -23,9 +25,9 @@
23 25 }
24 26
25 27 public function loadDatabase(string $databaseName): Database {
26 28 // TODO verify $databaseName
27 - $dir = realpath(__DIR__ . '/../../output');
29 + $dir = realpath(self::OUTPUT_DIR);
28 30 $file = $dir . '/' . $databaseName . '.db';
29 31
30 32 $db = new Database();
31 33 $db->q = new Queue($file);
@@ -36,9 +38,9 @@
36 38 }
37 39
38 40 public function deleteDatabase(string $databaseName) {
39 41 // TODO verify $databaseName
40 - $dir = realpath(__DIR__ . '/../../output');
42 + $dir = realpath(self::OUTPUT_DIR);
41 43 $file = $dir . '/' . $databaseName . '.db';
42 44 $success = wp_delete_file($file);
43 45 }
44 46