Skip to content

Commit

Permalink
pickFiles - Extract methods getPath() and getAll()
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Jul 21, 2022
1 parent b5dcea5 commit 93dd7a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
20 changes: 20 additions & 0 deletions util/pickFiles.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@

class UpgradeSnapshots {

/**
* Get the base-path of the snapshot data.
*
* @return string
*/
public static function getPath(): string {
return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'databases';
}

public static function getAll(): array {
$dbDir = static::getPath() . DIRECTORY_SEPARATOR;
$allFiles = array_merge(
(array) glob("{$dbDir}*.sql.bz2"),
(array) glob("{$dbDir}*.sql.gz"),
(array) glob("{$dbDir}*.mysql.bz2"),
(array) glob("{$dbDir}*.mysql.gz")
);
return $allFiles;
}

/**
* @param string $a
* Filter expression that selects range of test examples.
Expand Down
10 changes: 2 additions & 8 deletions util/pickFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ function main($args) {
return 1;
}

$dbDir = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'databases' . DIRECTORY_SEPARATOR;
$allFiles = array_merge(
(array) glob("{$dbDir}*.sql.bz2"),
(array) glob("{$dbDir}*.sql.gz"),
(array) glob("{$dbDir}*.mysql.bz2"),
(array) glob("{$dbDir}*.mysql.gz")
);
$allFiles = UpgradeSnapshots::getAll();

$files = array();
$maxCount = 0;
Expand Down Expand Up @@ -73,7 +67,7 @@ function main($args) {
elseif (strpos($arg, '*')) {
$files = array_merge(
$files,
(array) glob($dbDir . $arg)
(array) glob(UpgradeSnapshots::getPath() . DIRECTORY_SEPARATOR . $arg)
);
}
else {
Expand Down

0 comments on commit 93dd7a1

Please sign in to comment.