aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Encryption
diff options
context:
space:
mode:
authorJ0WI <J0WI@users.noreply.github.com>2021-07-06 19:20:32 +0200
committerJ0WI <J0WI@users.noreply.github.com>2021-07-06 19:20:32 +0200
commitb344ff1a67539d3916601a4cc11248778dc0fbf8 (patch)
tree4c99b8a362ca3320c8ae27032626067ac79954af /lib/private/Encryption
parent9f04a7c71e71d6d6085539ab7f37db729d8aeadd (diff)
downloadnextcloud-server-b344ff1a67539d3916601a4cc11248778dc0fbf8.tar.gz
nextcloud-server-b344ff1a67539d3916601a4cc11248778dc0fbf8.zip
Refactor getEncryptionModule routine
Diffstat (limited to 'lib/private/Encryption')
-rw-r--r--lib/private/Encryption/Manager.php30
1 files changed, 13 insertions, 17 deletions
diff --git a/lib/private/Encryption/Manager.php b/lib/private/Encryption/Manager.php
index 20ac9b41bfd..55578ee25f4 100644
--- a/lib/private/Encryption/Manager.php
+++ b/lib/private/Encryption/Manager.php
@@ -177,17 +177,15 @@ class Manager implements IManager {
* @throws Exceptions\ModuleDoesNotExistsException
*/
public function getEncryptionModule($moduleId = '') {
- if (!empty($moduleId)) {
- if (isset($this->encryptionModules[$moduleId])) {
- return call_user_func($this->encryptionModules[$moduleId]['callback']);
- } else {
- $message = "Module with ID: $moduleId does not exist.";
- $hint = $this->l->t('Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator.', [$moduleId]);
- throw new Exceptions\ModuleDoesNotExistsException($message, $hint);
- }
- } else {
+ if (empty($moduleId)) {
return $this->getDefaultEncryptionModule();
}
+ if (isset($this->encryptionModules[$moduleId])) {
+ return call_user_func($this->encryptionModules[$moduleId]['callback']);
+ }
+ $message = "Module with ID: $moduleId does not exist.";
+ $hint = $this->l->t('Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator.', [$moduleId]);
+ throw new Exceptions\ModuleDoesNotExistsException($message, $hint);
}
/**
@@ -198,17 +196,15 @@ class Manager implements IManager {
*/
protected function getDefaultEncryptionModule() {
$defaultModuleId = $this->getDefaultEncryptionModuleId();
- if (!empty($defaultModuleId)) {
- if (isset($this->encryptionModules[$defaultModuleId])) {
- return call_user_func($this->encryptionModules[$defaultModuleId]['callback']);
- } else {
- $message = 'Default encryption module not loaded';
- throw new Exceptions\ModuleDoesNotExistsException($message);
- }
- } else {
+ if (empty($defaultModuleId)) {
$message = 'No default encryption module defined';
throw new Exceptions\ModuleDoesNotExistsException($message);
}
+ if (isset($this->encryptionModules[$defaultModuleId])) {
+ return call_user_func($this->encryptionModules[$defaultModuleId]['callback']);
+ }
+ $message = 'Default encryption module not loaded';
+ throw new Exceptions\ModuleDoesNotExistsException($message);
}
/**