Passed
Pull Request — master (#686)
by Vitor
04:31
created
lib/Provider/Gateway/Factory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@
 block discarded – undo
13 13
 
14 14
 /** @extends AFactory<AGateway> */
15 15
 class Factory extends AFactory {
16
-	#[\Override]
16
+	#[\Override ]
17 17
 	protected function getPrefix(): string {
18 18
 		return 'OCA\\TwoFactorGateway\\Provider\\Channel\\';
19 19
 	}
20 20
 
21
-	#[\Override]
21
+	#[\Override ]
22 22
 	protected function getSuffix(): string {
23 23
 		return 'Gateway';
24 24
 	}
25 25
 
26
-	#[\Override]
26
+	#[\Override ]
27 27
 	protected function getBaseClass(): string {
28 28
 		return AGateway::class;
29 29
 	}
Please login to merge, or discard this patch.
lib/Provider/FieldDefinition.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	) {
34 34
 	}
35 35
 
36
-	#[\Override]
36
+	#[\Override ]
37 37
 	public function jsonSerialize(): mixed {
38 38
 		return [
39 39
 			'field' => $this->field,
Please login to merge, or discard this patch.
lib/Provider/AProvider.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	protected IGateway $gateway;
38 38
 
39 39
 	private function getSessionKey(): string {
40
-		return 'twofactor_gateway_' . $this->getGatewayName() . '_secret';
40
+		return 'twofactor_gateway_'.$this->getGatewayName().'_secret';
41 41
 	}
42 42
 
43 43
 	public function __construct(
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
 		}
59 59
 		$fqcn = static::class;
60 60
 		$parts = explode('\\', $fqcn);
61
-		[$name] = array_slice($parts, -2, 1);
61
+		[ $name ] = array_slice($parts, -2, 1);
62 62
 		$this->gatewayName = strtolower($name);
63 63
 		return $this->gatewayName;
64 64
 	}
65 65
 
66
-	#[\Override]
66
+	#[\Override ]
67 67
 	public function getId(): string {
68
-		return 'gateway_' . $this->getGatewayName();
68
+		return 'gateway_'.$this->getGatewayName();
69 69
 	}
70 70
 
71 71
 	private function getSecret(): string {
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		return $secret;
80 80
 	}
81 81
 
82
-	#[\Override]
82
+	#[\Override ]
83 83
 	public function getTemplate(IUser $user): ITemplate {
84 84
 		$secret = $this->getSecret();
85 85
 
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 			$identifier = $this->stateStorage->get($user, $this->getGatewayName())->getIdentifier() ?? '';
88 88
 
89 89
 			$message = $this->gateway->getSettings()->allow_markdown ?? false
90
-				? $this->l10n->t('`%s` is your Nextcloud authentication code', [$secret])
91
-				: $this->l10n->t('%s is your Nextcloud authentication code', [$secret]);
90
+				? $this->l10n->t('`%s` is your Nextcloud authentication code', [ $secret ])
91
+				: $this->l10n->t('%s is your Nextcloud authentication code', [ $secret ]);
92 92
 
93 93
 			$this->gateway->send(
94 94
 				$identifier,
95 95
 				$message,
96
-				['code' => $secret],
96
+				[ 'code' => $secret ],
97 97
 			);
98 98
 		} catch (MessageTransmissionException) {
99 99
 			return $this->templateManager->getTemplate('twofactor_gateway', 'error');
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		return $tmpl;
105 105
 	}
106 106
 
107
-	#[\Override]
107
+	#[\Override ]
108 108
 	public function verifyChallenge(IUser $user, string $challenge): bool {
109 109
 		$valid = $this->session->exists($this->getSessionKey())
110 110
 			&& $this->session->get($this->getSessionKey()) === $challenge;
@@ -116,31 +116,31 @@  discard block
 block discarded – undo
116 116
 		return $valid;
117 117
 	}
118 118
 
119
-	#[\Override]
119
+	#[\Override ]
120 120
 	public function isTwoFactorAuthEnabledForUser(IUser $user): bool {
121 121
 		return $this->stateStorage->get($user, $this->getGatewayName())->getState() === StateStorage::STATE_ENABLED;
122 122
 	}
123 123
 
124
-	#[\Override]
124
+	#[\Override ]
125 125
 	public function getPersonalSettings(IUser $user): IPersonalProviderSettings {
126
-		$this->initialState->provideInitialState('settings-' . $this->gateway->getProviderId(), $this->gateway->getSettings());
126
+		$this->initialState->provideInitialState('settings-'.$this->gateway->getProviderId(), $this->gateway->getSettings());
127 127
 		return new PersonalSettings(
128 128
 			$this->getGatewayName(),
129 129
 			$this->gateway->isComplete(),
130 130
 		);
131 131
 	}
132 132
 
133
-	#[\Override]
133
+	#[\Override ]
134 134
 	public function getLightIcon(): String {
135 135
 		return Server::get(IURLGenerator::class)->imagePath(Application::APP_ID, 'app.svg');
136 136
 	}
137 137
 
138
-	#[\Override]
138
+	#[\Override ]
139 139
 	public function getDarkIcon(): String {
140 140
 		return Server::get(IURLGenerator::class)->imagePath(Application::APP_ID, 'app-dark.svg');
141 141
 	}
142 142
 
143
-	#[\Override]
143
+	#[\Override ]
144 144
 	public function disableFor(IUser $user) {
145 145
 		$state = $this->stateStorage->get($user, $this->getGatewayName());
146 146
 		if ($state->getState() === StateStorage::STATE_ENABLED) {
Please login to merge, or discard this patch.
lib/Provider/Channel/Telegram/Provider/Drivers/ClientCli/Cli.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@
 block discarded – undo
9 9
  */
10 10
 
11 11
 /** @todo see the README.md in this directory */
12
-require __DIR__ . '/../../../../../../../vendor-bin/telegram-client/vendor/autoload.php';
13
-require __DIR__ . '/Login.php';
14
-require __DIR__ . '/SendMessage.php';
12
+require __DIR__.'/../../../../../../../vendor-bin/telegram-client/vendor/autoload.php';
13
+require __DIR__.'/Login.php';
14
+require __DIR__.'/SendMessage.php';
15 15
 
16 16
 use OCA\TwoFactorGateway\Provider\Channel\Telegram\Provider\Drivers\ClientCli\Login;
17 17
 use OCA\TwoFactorGateway\Provider\Channel\Telegram\Provider\Drivers\ClientCli\SendMessage;
Please login to merge, or discard this patch.
lib/Provider/Channel/Telegram/Factory.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,31 +15,31 @@
 block discarded – undo
15 15
 
16 16
 /** @extends AFactory<AProvider> */
17 17
 class Factory extends AFactory {
18
-	#[\Override]
18
+	#[\Override ]
19 19
 	protected function getPrefix(): string {
20 20
 		return 'OCA\\TwoFactorGateway\\Provider\\Channel\\Telegram\\Provider\\Drivers\\';
21 21
 	}
22 22
 
23
-	#[\Override]
23
+	#[\Override ]
24 24
 	protected function getSuffix(): string {
25 25
 		return '';
26 26
 	}
27 27
 
28
-	#[\Override]
28
+	#[\Override ]
29 29
 	protected function getBaseClass(): string {
30 30
 		return AProvider::class;
31 31
 	}
32 32
 
33
-	#[\Override]
33
+	#[\Override ]
34 34
 	public function get(string $name): object {
35
-		if (isset($this->instances[$name])) {
36
-			return $this->instances[$name];
35
+		if (isset($this->instances[ $name ])) {
36
+			return $this->instances[ $name ];
37 37
 		}
38 38
 		foreach ($this->getFqcnList() as $fqcn) {
39 39
 			$instance = \OCP\Server::get($fqcn);
40 40
 			if ($instance->getSettings()->id === $name) {
41 41
 				$instance->setAppConfig(\OCP\Server::get(\OCP\IAppConfig::class));
42
-				$this->instances[$name] = $instance;
42
+				$this->instances[ $name ] = $instance;
43 43
 				return $instance;
44 44
 			}
45 45
 		}
Please login to merge, or discard this patch.
lib/Provider/AFactory.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
  */
14 14
 abstract class AFactory {
15 15
 	/** @var array<string, T> */
16
-	protected array $instances = [];
16
+	protected array $instances = [ ];
17 17
 	/** @var array<string> */
18
-	protected array $fqcn = [];
18
+	protected array $fqcn = [ ];
19 19
 
20 20
 	abstract protected function getPrefix(): string;
21 21
 
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 			true => $this->typeFrom($name),
34 34
 			false => strtolower($name),
35 35
 		};
36
-		if (isset($this->instances[$needle])) {
37
-			return $this->instances[$needle];
36
+		if (isset($this->instances[ $needle ])) {
37
+			return $this->instances[ $needle ];
38 38
 		}
39 39
 
40 40
 		foreach ($this->getFqcnList() as $fqcn) {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 				continue;
44 44
 			}
45 45
 			$instance = \OCP\Server::get($fqcn);
46
-			$this->instances[$type] = $instance;
46
+			$this->instances[ $type ] = $instance;
47 47
 			return $instance;
48 48
 		}
49 49
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 			return $this->fqcn;
57 57
 		}
58 58
 
59
-		$loader = require __DIR__ . '/../../vendor/autoload.php';
59
+		$loader = require __DIR__.'/../../vendor/autoload.php';
60 60
 		foreach ($loader->getClassMap() as $fqcn => $_) {
61 61
 			$type = $this->typeFrom($fqcn);
62 62
 			if ($type === null) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			if (!is_subclass_of($fqcn, $this->getBaseClass(), true)) {
66 66
 				continue;
67 67
 			}
68
-			$this->fqcn[] = $fqcn;
68
+			$this->fqcn[ ] = $fqcn;
69 69
 		}
70 70
 		return $this->fqcn;
71 71
 	}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 			return null;
81 81
 		}
82 82
 		$type = substr($fqcn, strlen($prefix));
83
-		$type = substr($type, 0, -strlen('\\' . $suffix));
83
+		$type = substr($type, 0, -strlen('\\'.$suffix));
84 84
 		if (strpos($type, '\\') !== false || $type === '') {
85 85
 			return null;
86 86
 		}
Please login to merge, or discard this patch.
lib/Provider/Channel/Telegram/Provider/AProvider.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@  discard block
 block discarded – undo
24 24
 	/**
25 25
 	 * @throws MessageTransmissionException
26 26
 	 */
27
-	#[\Override]
27
+	#[\Override ]
28 28
 	abstract public function send(string $identifier, string $message);
29 29
 
30
-	#[\Override]
30
+	#[\Override ]
31 31
 	public function setAppConfig(IAppConfig $appConfig): void {
32 32
 		$this->appConfig = $appConfig;
33 33
 	}
34 34
 
35
-	#[\Override]
35
+	#[\Override ]
36 36
 	public function getSettings(): Settings {
37 37
 		if ($this->settings !== null) {
38 38
 			return $this->settings;
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 		return $this->settings = $this->createSettings();
41 41
 	}
42 42
 
43
-	#[\Override]
43
+	#[\Override ]
44 44
 	public static function idOverride(): ?string {
45 45
 		return null;
46 46
 	}
47 47
 
48
-	#[\Override]
48
+	#[\Override ]
49 49
 	public function getProviderId(): string {
50 50
 		$settings = $this->getSettings();
51 51
 		if (!empty($settings->id)) {
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 		}
54 54
 		$id = self::getIdFromProviderFqcn(static::class);
55 55
 		if ($id === null) {
56
-			throw new \LogicException('Cannot derive gateway id from FQCN: ' . static::class);
56
+			throw new \LogicException('Cannot derive gateway id from FQCN: '.static::class);
57 57
 		}
58 58
 		return $id;
59 59
 	}
60 60
 
61
-	#[\Override]
61
+	#[\Override ]
62 62
 	abstract public function cliConfigure(InputInterface $input, OutputInterface $output): int;
63 63
 
64 64
 	private static function getIdFromProviderFqcn(string $fqcn): ?string {
Please login to merge, or discard this patch.
lib/Provider/Channel/SMS/Provider/AProvider.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * @throws MessageTransmissionException
24 24
 	 */
25
-	#[\Override]
25
+	#[\Override ]
26 26
 	abstract public function send(string $identifier, string $message);
27 27
 
28
-	#[\Override]
28
+	#[\Override ]
29 29
 	public function setAppConfig(IAppConfig $appConfig): void {
30 30
 		$this->appConfig = $appConfig;
31 31
 	}
32 32
 
33
-	#[\Override]
33
+	#[\Override ]
34 34
 	public function getSettings(): Settings {
35 35
 		if ($this->settings !== null) {
36 36
 			return $this->settings;
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 		return $this->settings = $this->createSettings();
39 39
 	}
40 40
 
41
-	#[\Override]
41
+	#[\Override ]
42 42
 	public static function idOverride(): ?string {
43 43
 		return null;
44 44
 	}
45 45
 
46
-	#[\Override]
46
+	#[\Override ]
47 47
 	public function getProviderId(): string {
48 48
 		$settings = $this->getSettings();
49 49
 		if (!empty($settings->id)) {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		}
52 52
 		$id = self::getIdFromProviderFqcn(static::class);
53 53
 		if ($id === null) {
54
-			throw new \LogicException('Cannot derive gateway id from FQCN: ' . static::class);
54
+			throw new \LogicException('Cannot derive gateway id from FQCN: '.static::class);
55 55
 		}
56 56
 		return $id;
57 57
 	}
Please login to merge, or discard this patch.
lib/Provider/Channel/SMS/Gateway.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 		parent::__construct($appConfig);
30 30
 	}
31 31
 
32
-	#[\Override]
33
-	public function send(string $identifier, string $message, array $extra = []): void {
32
+	#[\Override ]
33
+	public function send(string $identifier, string $message, array $extra = [ ]): void {
34 34
 		$this->getProvider()->send($identifier, $message);
35 35
 	}
36 36
 
37
-	#[\Override]
37
+	#[\Override ]
38 38
 	final public function cliConfigure(InputInterface $input, OutputInterface $output): int {
39 39
 		$namespaces = $this->smsProviderFactory->getFqcnList();
40
-		$names = [];
41
-		$providers = [];
40
+		$names = [ ];
41
+		$providers = [ ];
42 42
 		foreach ($namespaces as $ns) {
43 43
 			$provider = $this->smsProviderFactory->get($ns);
44
-			$providers[] = $this->smsProviderFactory->get($ns);
45
-			$names[] = $provider->getSettings()->name;
44
+			$providers[ ] = $this->smsProviderFactory->get($ns);
45
+			$names[ ] = $provider->getSettings()->name;
46 46
 		}
47 47
 
48 48
 		$helper = new QuestionHelper();
@@ -50,29 +50,29 @@  discard block
 block discarded – undo
50 50
 		$name = $helper->ask($input, $output, $choiceQuestion);
51 51
 		$selectedIndex = array_search($name, $names);
52 52
 
53
-		$provider = $providers[$selectedIndex];
53
+		$provider = $providers[ $selectedIndex ];
54 54
 
55 55
 		foreach ($provider->getSettings()->fields as $field) {
56 56
 			$id = $field->field;
57
-			$prompt = $field->prompt . ' ';
57
+			$prompt = $field->prompt.' ';
58 58
 			$defaultVal = $field->default ?? null;
59 59
 			$optional = (bool)($field->optional ?? false);
60 60
 
61 61
 			$answer = (string)$helper->ask($input, $output, new Question($prompt, $defaultVal));
62 62
 
63 63
 			if ($optional && $answer === '') {
64
-				$method = 'delete' . $this->toCamel($id);
64
+				$method = 'delete'.$this->toCamel($id);
65 65
 				$provider->{$method}();
66 66
 				continue;
67 67
 			}
68 68
 
69
-			$method = 'set' . $this->toCamel($id);
69
+			$method = 'set'.$this->toCamel($id);
70 70
 			$provider->{$method}($answer);
71 71
 		}
72 72
 		return 0;
73 73
 	}
74 74
 
75
-	#[\Override]
75
+	#[\Override ]
76 76
 	public function createSettings(): Settings {
77 77
 		try {
78 78
 			$settings = $this->getProvider()->getSettings();
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		return $settings;
85 85
 	}
86 86
 
87
-	#[\Override]
87
+	#[\Override ]
88 88
 	public function isComplete(?Settings $settings = null): bool {
89 89
 		if ($settings === null) {
90 90
 			try {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		return parent::isComplete($settings);
98 98
 	}
99 99
 
100
-	#[\Override]
100
+	#[\Override ]
101 101
 	public function remove(?Settings $settings = null): void {
102 102
 		if (!is_object($settings)) {
103 103
 			$settings = $this->getSettings();
Please login to merge, or discard this patch.