From 6b795da540d50f2ca1e70a284a7367390621b50b Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Thu, 3 Aug 2023 14:50:33 +0330 Subject: Uses early returns. To improve code readability. Signed-off-by: Faraz Samapoor --- .../encryption/lib/Command/FixEncryptedVersion.php | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'apps/encryption/lib/Command/FixEncryptedVersion.php') diff --git a/apps/encryption/lib/Command/FixEncryptedVersion.php b/apps/encryption/lib/Command/FixEncryptedVersion.php index faeb0348222..d2764036b39 100644 --- a/apps/encryption/lib/Command/FixEncryptedVersion.php +++ b/apps/encryption/lib/Command/FixEncryptedVersion.php @@ -79,6 +79,11 @@ class FixEncryptedVersion extends Command { $all = $input->getOption('all'); $pathOption = \trim(($input->getOption('path') ?? ''), '/'); + if (!$user && !$all) { + $output->writeln("Either a user id or --all needs to be provided"); + return self::FAILURE; + } + if ($user) { if ($all) { $output->writeln("Specifying a user id and --all are mutually exclusive"); @@ -91,18 +96,15 @@ class FixEncryptedVersion extends Command { } return $this->runForUser($user, $pathOption, $output); - } elseif ($all) { - $result = 0; - $this->userManager->callForSeenUsers(function (IUser $user) use ($pathOption, $output, &$result) { - $output->writeln("Processing files for " . $user->getUID()); - $result = $this->runForUser($user->getUID(), $pathOption, $output); - return $result === 0; - }); - return $result; - } else { - $output->writeln("Either a user id or --all needs to be provided"); - return self::FAILURE; } + + $result = 0; + $this->userManager->callForSeenUsers(function (IUser $user) use ($pathOption, $output, &$result) { + $output->writeln("Processing files for " . $user->getUID()); + $result = $this->runForUser($user->getUID(), $pathOption, $output); + return $result === 0; + }); + return $result; } private function runForUser(string $user, string $pathOption, OutputInterface $output): int { -- cgit v1.2.3