summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib
diff options
context:
space:
mode:
authorRobin Windey <ro.windey@gmail.com>2023-08-13 16:34:06 +0000
committerRobin Windey <ro.windey@gmail.com>2023-08-18 07:25:39 +0200
commit52d77eb9fe367a55dd0e8dc05abf7be6b00e298c (patch)
tree7619888f68b54090c6322c176424eabe467aa2a6 /apps/files_trashbin/lib
parentee66518ca25c53836a9b8a6eb3c17d46e3be8251 (diff)
downloadnextcloud-server-52d77eb9fe367a55dd0e8dc05abf7be6b00e298c.tar.gz
nextcloud-server-52d77eb9fe367a55dd0e8dc05abf7be6b00e298c.zip
Make scope parsing more readable
Signed-off-by: GitHub <noreply@github.com>
Diffstat (limited to 'apps/files_trashbin/lib')
-rw-r--r--apps/files_trashbin/lib/Command/RestoreAllFiles.php19
1 files changed, 10 insertions, 9 deletions
diff --git a/apps/files_trashbin/lib/Command/RestoreAllFiles.php b/apps/files_trashbin/lib/Command/RestoreAllFiles.php
index 1e852c3658e..172e1af385b 100644
--- a/apps/files_trashbin/lib/Command/RestoreAllFiles.php
+++ b/apps/files_trashbin/lib/Command/RestoreAllFiles.php
@@ -39,6 +39,12 @@ class RestoreAllFiles extends Base {
private const SCOPE_USER = 1;
private const SCOPE_GROUPFOLDERS = 2;
+ private static $SCOPE_MAP = [
+ 'user' => self::SCOPE_USER,
+ 'groupfolders' => self::SCOPE_GROUPFOLDERS,
+ 'all' => self::SCOPE_ALL
+ ];
+
/** @var IUserManager */
protected $userManager;
@@ -243,16 +249,11 @@ class RestoreAllFiles extends Base {
* @return int
*/
protected function parseScope(string $scope): int {
- switch ($scope) {
- case 'user':
- return self::SCOPE_USER;
- case 'groupfolders':
- return self::SCOPE_GROUPFOLDERS;
- case 'all':
- return self::SCOPE_ALL;
- default:
- throw new InvalidOptionException("Invalid scope '$scope'");
+ if (isset(self::$SCOPE_MAP[$scope])) {
+ return self::$SCOPE_MAP[$scope];
}
+
+ throw new InvalidOptionException("Invalid scope '$scope'");
}
/**