Completed
Pull Request — master (#10023)
by Joas
206:15 queued 184:34
created
core/Command/TwoFactorAuth/State.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -34,73 +34,73 @@
 block discarded – undo
34 34
 
35 35
 class State extends Base {
36 36
 
37
-	/** @var IRegistry */
38
-	private $registry;
39
-
40
-	public function __construct(IRegistry $registry, IUserManager $userManager) {
41
-		parent::__construct('twofactorauth:state');
42
-
43
-		$this->registry = $registry;
44
-		$this->userManager = $userManager;
45
-	}
46
-
47
-	protected function configure() {
48
-		parent::configure();
49
-
50
-		$this->setName('twofactorauth:state');
51
-		$this->setDescription('Get the two-factor authentication (2FA) state of a user');
52
-		$this->addArgument('uid', InputArgument::REQUIRED);
53
-	}
54
-
55
-	protected function execute(InputInterface $input, OutputInterface $output) {
56
-		$uid = $input->getArgument('uid');
57
-		$user = $this->userManager->get($uid);
58
-		if (is_null($user)) {
59
-			$output->writeln("<error>Invalid UID</error>");
60
-			return;
61
-		}
62
-
63
-		$providerStates = $this->registry->getProviderStates($user);
64
-		$filtered = $this->filterEnabledDisabledUnknownProviders($providerStates);
65
-		list ($enabled, $disabled) = $filtered;
66
-
67
-		if (!empty($enabled)) {
68
-			$output->writeln("Two-factor authentication is enabled for user $uid");
69
-		} else {
70
-			$output->writeln("Two-factor authentication is not enabled for user $uid");
71
-		}
72
-
73
-		$output->writeln("");
74
-		$this->printProviders("Enabled providers", $enabled, $output);
75
-		$this->printProviders("Disabled providers", $disabled, $output);
76
-	}
77
-
78
-	private function filterEnabledDisabledUnknownProviders(array $providerStates): array {
79
-		$enabled = [];
80
-		$disabled = [];
81
-
82
-		foreach ($providerStates as $providerId => $isEnabled) {
83
-			if ($isEnabled) {
84
-				$enabled[] = $providerId;
85
-			} else {
86
-				$disabled[] = $providerId;
87
-			}
88
-		}
89
-
90
-		return [$enabled, $disabled];
91
-	}
92
-
93
-	private function printProviders(string $title, array $providers,
94
-		OutputInterface $output) {
95
-		if (empty($providers)) {
96
-			// Ignore and don't print anything
97
-			return;
98
-		}
99
-
100
-		$output->writeln($title . ":");
101
-		foreach ($providers as $provider) {
102
-			$output->writeln("- " . $provider);
103
-		}
104
-	}
37
+    /** @var IRegistry */
38
+    private $registry;
39
+
40
+    public function __construct(IRegistry $registry, IUserManager $userManager) {
41
+        parent::__construct('twofactorauth:state');
42
+
43
+        $this->registry = $registry;
44
+        $this->userManager = $userManager;
45
+    }
46
+
47
+    protected function configure() {
48
+        parent::configure();
49
+
50
+        $this->setName('twofactorauth:state');
51
+        $this->setDescription('Get the two-factor authentication (2FA) state of a user');
52
+        $this->addArgument('uid', InputArgument::REQUIRED);
53
+    }
54
+
55
+    protected function execute(InputInterface $input, OutputInterface $output) {
56
+        $uid = $input->getArgument('uid');
57
+        $user = $this->userManager->get($uid);
58
+        if (is_null($user)) {
59
+            $output->writeln("<error>Invalid UID</error>");
60
+            return;
61
+        }
62
+
63
+        $providerStates = $this->registry->getProviderStates($user);
64
+        $filtered = $this->filterEnabledDisabledUnknownProviders($providerStates);
65
+        list ($enabled, $disabled) = $filtered;
66
+
67
+        if (!empty($enabled)) {
68
+            $output->writeln("Two-factor authentication is enabled for user $uid");
69
+        } else {
70
+            $output->writeln("Two-factor authentication is not enabled for user $uid");
71
+        }
72
+
73
+        $output->writeln("");
74
+        $this->printProviders("Enabled providers", $enabled, $output);
75
+        $this->printProviders("Disabled providers", $disabled, $output);
76
+    }
77
+
78
+    private function filterEnabledDisabledUnknownProviders(array $providerStates): array {
79
+        $enabled = [];
80
+        $disabled = [];
81
+
82
+        foreach ($providerStates as $providerId => $isEnabled) {
83
+            if ($isEnabled) {
84
+                $enabled[] = $providerId;
85
+            } else {
86
+                $disabled[] = $providerId;
87
+            }
88
+        }
89
+
90
+        return [$enabled, $disabled];
91
+    }
92
+
93
+    private function printProviders(string $title, array $providers,
94
+        OutputInterface $output) {
95
+        if (empty($providers)) {
96
+            // Ignore and don't print anything
97
+            return;
98
+        }
99
+
100
+        $output->writeln($title . ":");
101
+        foreach ($providers as $provider) {
102
+            $output->writeln("- " . $provider);
103
+        }
104
+    }
105 105
 
106 106
 }
Please login to merge, or discard this patch.