Passed
Push — master ( 989b71...22fa84 )
by
unknown
01:48
created
lib/Provider/Channel/Telegram/Provider/Drivers/ClientCli/SendMessage.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use Symfony\Component\Console\Input\InputOption;
19 19
 use Symfony\Component\Console\Output\OutputInterface;
20 20
 
21
-#[AsCommand(name: 'telegram:send-message', description: 'Send a message via Telegram Client API')]
21
+#[AsCommand(name: 'telegram:send-message', description: 'Send a message via Telegram Client API') ]
22 22
 class SendMessage extends Command {
23 23
 
24 24
 	protected function configure(): void {
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 		try {
50 50
 			$settings = (new Settings())
51
-				->setLogger((new Logger())->setExtra($sessionDirectory . '/MadelineProto.log'));
51
+				->setLogger((new Logger())->setExtra($sessionDirectory.'/MadelineProto.log'));
52 52
 
53 53
 			$message = $input->getOption('message');
54 54
 			$peer = $input->getOption('to');
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 			if (!str_starts_with($peer, '@')) {
61 61
 				try {
62 62
 					$result = $api->contacts->resolvePhone(phone: $peer);
63
-					$peer = $result['peer'];
63
+					$peer = $result[ 'peer' ];
64 64
 				} catch (RPCErrorException $e) {
65 65
 					if ($e->getMessage() === 'PHONE_NOT_OCCUPIED') {
66 66
 						$output->writeln('<error>Error: The phone number is not associated with any Telegram account.</error>');
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
 			return Command::SUCCESS;
83 83
 		} catch (\Throwable $e) {
84
-			$output->writeln('<error>Error: ' . $e->getMessage() . '</error>');
84
+			$output->writeln('<error>Error: '.$e->getMessage().'</error>');
85 85
 			return Command::FAILURE;
86 86
 		}
87 87
 	}
Please login to merge, or discard this patch.
lib/Provider/Channel/WhatsApp/Gateway.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		'name' => 'WhatsApp',
39 39
 		'allow_markdown' => true,
40 40
 		'fields' => [
41
-			['field' => 'base_url', 'prompt' => 'Base URL to your WhatsApp API endpoint:'],
41
+			[ 'field' => 'base_url', 'prompt' => 'Base URL to your WhatsApp API endpoint:' ],
42 42
 		],
43 43
 	];
44 44
 	private string $instanceId;
@@ -56,24 +56,24 @@  discard block
 block discarded – undo
56 56
 		$this->client = $this->clientService->newClient();
57 57
 	}
58 58
 
59
-	#[\Override]
60
-	public function send(string $identifier, string $message, array $extra = []): void {
59
+	#[\Override ]
60
+	public function send(string $identifier, string $message, array $extra = [ ]): void {
61 61
 		$this->logger->debug("sending whatsapp message to $identifier, message: $message");
62 62
 
63 63
 		$response = $this->getSessionStatus();
64 64
 		if ($response !== 'CONNECTED') {
65
-			throw new MessageTransmissionException('WhatsApp session is not connected. Current status: ' . $response);
65
+			throw new MessageTransmissionException('WhatsApp session is not connected. Current status: '.$response);
66 66
 		}
67 67
 
68 68
 		$chatId = $this->getChatIdFromPhoneNumber($identifier);
69 69
 
70 70
 		try {
71
-			$response = $this->client->post($this->getBaseUrl() . '/client/sendMessage/' . $this->instanceId, [
71
+			$response = $this->client->post($this->getBaseUrl().'/client/sendMessage/'.$this->instanceId, [
72 72
 				'json' => [
73 73
 					'chatId' => $chatId,
74 74
 					'contentType' => 'string',
75 75
 					'content' => $message,
76
-					'options' => [],
76
+					'options' => [ ],
77 77
 				],
78 78
 			]);
79 79
 		} catch (\Exception $e) {
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 		$this->logger->debug("whatsapp message to chat $identifier sent");
88 88
 	}
89 89
 
90
-	#[\Override]
90
+	#[\Override ]
91 91
 	public function cliConfigure(InputInterface $input, OutputInterface $output): int {
92 92
 		$helper = new QuestionHelper();
93
-		$baseUrlQuestion = new Question(self::SCHEMA['fields'][0]['prompt'] . ' ');
93
+		$baseUrlQuestion = new Question(self::SCHEMA[ 'fields' ][ 0 ][ 'prompt' ].' ');
94 94
 		$this->lazyBaseUrl = $helper->ask($input, $output, $baseUrlQuestion);
95 95
 		$this->lazyBaseUrl = rtrim($this->lazyBaseUrl, '/');
96 96
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 				return 1;
100 100
 			}
101 101
 		} catch (\Exception $e) {
102
-			$output->writeln('<error>' . $e->getMessage() . '</error>');
102
+			$output->writeln('<error>'.$e->getMessage().'</error>');
103 103
 		}
104 104
 
105 105
 		$this->setBaseUrl($this->lazyBaseUrl);
@@ -109,23 +109,23 @@  discard block
 block discarded – undo
109 109
 
110 110
 	private function getChatIdFromPhoneNumber(string $phoneNumber): string {
111 111
 		try {
112
-			$response = $this->client->post($this->getBaseUrl() . '/client/getNumberId/' . $this->instanceId, [
112
+			$response = $this->client->post($this->getBaseUrl().'/client/getNumberId/'.$this->instanceId, [
113 113
 				'json' => [
114 114
 					'number' => preg_replace('/\D/', '', $phoneNumber),
115 115
 				],
116 116
 			]);
117 117
 			$json = $response->getBody();
118 118
 			$data = json_decode($json, true);
119
-			if (empty($data['result'])) {
119
+			if (empty($data[ 'result' ])) {
120 120
 				throw new MessageTransmissionException('The phone number is not registered on WhatsApp.');
121 121
 			}
122
-			return $data['result']['_serialized'];
122
+			return $data[ 'result' ][ '_serialized' ];
123 123
 		} catch (ServerException $e) {
124 124
 			$content = $e->getResponse()?->getBody()?->getContents();
125 125
 			if ($content === null) {
126 126
 				throw new MessageTransmissionException('Unknown error');
127 127
 			}
128
-			$errorMessage = json_decode($content, true)['error'] ?? 'Unknown error';
128
+			$errorMessage = json_decode($content, true)[ 'error' ] ?? 'Unknown error';
129 129
 			throw new MessageTransmissionException($errorMessage);
130 130
 		}
131 131
 	}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		}
140 140
 
141 141
 		/** @var string */
142
-		$this->lazyBaseUrl = $this->__call(__FUNCTION__, []);
142
+		$this->lazyBaseUrl = $this->__call(__FUNCTION__, [ ]);
143 143
 		return $this->lazyBaseUrl;
144 144
 	}
145 145
 
@@ -155,19 +155,19 @@  discard block
 block discarded – undo
155 155
 
156 156
 		$last = null;
157 157
 		while (true) {
158
-			$response = $this->client->get($this->getBaseUrl() . '/session/qr/' . $this->instanceId);
158
+			$response = $this->client->get($this->getBaseUrl().'/session/qr/'.$this->instanceId);
159 159
 			$json = $response->getBody();
160 160
 			$data = json_decode($json, true);
161
-			if ($data['success'] === false) {
162
-				if ($data['message'] === 'qr code not ready or already scanned') {
161
+			if ($data[ 'success' ] === false) {
162
+				if ($data[ 'message' ] === 'qr code not ready or already scanned') {
163 163
 					$output->writeln('<error>Session not connected yet, waiting...</error>');
164 164
 					sleep(2);
165 165
 					continue;
166 166
 				}
167
-				$output->writeln('<error>' . $data['message'] . '</error>');
167
+				$output->writeln('<error>'.$data[ 'message' ].'</error>');
168 168
 				return 1;
169 169
 			}
170
-			$qrCodeContent = $data['qr'];
170
+			$qrCodeContent = $data[ 'qr' ];
171 171
 
172 172
 			if ($qrCodeContent !== $last) {
173 173
 				$last = $qrCodeContent;
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	}
190 190
 
191 191
 	private function getSessionStatus(): string {
192
-		$endpoint = $this->getBaseUrl() . '/session/status/' . $this->instanceId;
192
+		$endpoint = $this->getBaseUrl().'/session/status/'.$this->instanceId;
193 193
 
194 194
 		try {
195 195
 			$response = $this->client->get($endpoint);
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
 				return 'not_connected';
201 201
 			}
202 202
 
203
-			if (($responseData['success'] ?? null) === false) {
204
-				$msg = $responseData['message'] ?? '';
205
-				return in_array($msg, ['session_not_found', 'session_not_connected'], true)
203
+			if (($responseData[ 'success' ] ?? null) === false) {
204
+				$msg = $responseData[ 'message' ] ?? '';
205
+				return in_array($msg, [ 'session_not_found', 'session_not_connected' ], true)
206 206
 					? $msg
207 207
 					: 'not_connected';
208 208
 			}
209 209
 
210
-			return (string)($responseData['state'] ?? 'not_connected');
210
+			return (string)($responseData[ 'state' ] ?? 'not_connected');
211 211
 		} catch (ClientException $e) {
212 212
 			return 'not_connected';
213 213
 		} catch (RequestException $e) {
214
-			$this->logger->info('Could not connect to ' . $endpoint, ['exception' => $e]);
214
+			$this->logger->info('Could not connect to '.$endpoint, [ 'exception' => $e ]);
215 215
 			throw new \Exception('Could not connect to the WhatsApp API. Please check the URL.', 1);
216 216
 		}
217 217
 	}
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	private function getSessionStart(): int {
233
-		$endpoint = $this->getBaseUrl() . '/session/start/' . $this->instanceId;
233
+		$endpoint = $this->getBaseUrl().'/session/start/'.$this->instanceId;
234 234
 		try {
235 235
 			$this->client->get($endpoint);
236 236
 		} catch (ClientException $e) {
237 237
 			return 1;
238 238
 		} catch (RequestException $e) {
239
-			$this->logger->info('Could not connect to ' . $endpoint, [
239
+			$this->logger->info('Could not connect to '.$endpoint, [
240 240
 				'exception' => $e,
241 241
 			]);
242 242
 			throw new \Exception('Could not connect to the WhatsApp API. Please check the URL.', 1);
Please login to merge, or discard this patch.
lib/Provider/Channel/SMS/Gateway.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
 		parent::__construct($appConfig);
33 33
 	}
34 34
 
35
-	#[\Override]
36
-	public function send(string $identifier, string $message, array $extra = []): void {
35
+	#[\Override ]
36
+	public function send(string $identifier, string $message, array $extra = [ ]): void {
37 37
 		$this->getProvider()->send($identifier, $message);
38 38
 	}
39 39
 
40
-	#[\Override]
40
+	#[\Override ]
41 41
 	final public function cliConfigure(InputInterface $input, OutputInterface $output): int {
42 42
 		$namespaces = $this->providerFactory->getFqcnList();
43
-		$schemas = [];
43
+		$schemas = [ ];
44 44
 		foreach ($namespaces as $ns) {
45
-			$schemas[] = $ns::SCHEMA;
45
+			$schemas[ ] = $ns::SCHEMA;
46 46
 		}
47 47
 		$names = array_column($schemas, 'name');
48 48
 
@@ -50,31 +50,31 @@  discard block
 block discarded – undo
50 50
 		$choiceQuestion = new ChoiceQuestion('Please choose a SMS provider:', $names);
51 51
 		$name = $helper->ask($input, $output, $choiceQuestion);
52 52
 		$selectedIndex = array_search($name, $names);
53
-		$schema = $schemas[$selectedIndex];
53
+		$schema = $schemas[ $selectedIndex ];
54 54
 
55
-		$provider = $this->getProvider($namespaces[$selectedIndex]::getProviderId());
55
+		$provider = $this->getProvider($namespaces[ $selectedIndex ]::getProviderId());
56 56
 
57
-		foreach ($schema['fields'] as $field) {
58
-			$id = $field['field'];
59
-			$prompt = $field['prompt'] . ' ';
60
-			$defaultVal = $field['default'] ?? null;
61
-			$optional = (bool)($field['optional'] ?? false);
57
+		foreach ($schema[ 'fields' ] as $field) {
58
+			$id = $field[ 'field' ];
59
+			$prompt = $field[ 'prompt' ].' ';
60
+			$defaultVal = $field[ 'default' ] ?? null;
61
+			$optional = (bool)($field[ 'optional' ] ?? false);
62 62
 
63 63
 			$answer = (string)$helper->ask($input, $output, new Question($prompt, $defaultVal));
64 64
 
65 65
 			if ($optional && $answer === '') {
66
-				$method = 'delete' . $this->toCamel($id);
66
+				$method = 'delete'.$this->toCamel($id);
67 67
 				$provider->{$method}();
68 68
 				continue;
69 69
 			}
70 70
 
71
-			$method = 'set' . $this->toCamel($id);
71
+			$method = 'set'.$this->toCamel($id);
72 72
 			$provider->{$method}($answer);
73 73
 		}
74 74
 		return 0;
75 75
 	}
76 76
 
77
-	#[\Override]
77
+	#[\Override ]
78 78
 	public function getSettings(): array {
79 79
 		try {
80 80
 			$provider = $this->getProvider();
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 		return $provider::SCHEMA;
85 85
 	}
86 86
 
87
-	#[\Override]
88
-	public function isComplete(array $schema = []): bool {
87
+	#[\Override ]
88
+	public function isComplete(array $schema = [ ]): bool {
89 89
 		if (empty($schema)) {
90 90
 			try {
91 91
 				$provider = $this->getProvider();
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 		return parent::isComplete($schema);
98 98
 	}
99 99
 
100
-	#[\Override]
101
-	public function remove(array $schema = []): void {
100
+	#[\Override ]
101
+	public function remove(array $schema = [ ]): void {
102 102
 		if (empty($schema)) {
103 103
 			$schema = static::SCHEMA;
104 104
 		}
Please login to merge, or discard this patch.
lib/Provider/Gateway/AGateway.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 abstract class AGateway implements IGateway {
19 19
 	use TConfigurable;
20
-	public const SCHEMA = [];
20
+	public const SCHEMA = [ ];
21 21
 
22 22
 	public function __construct(
23 23
 		public IAppConfig $appConfig,
@@ -27,42 +27,42 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @throws MessageTransmissionException
29 29
 	 */
30
-	#[\Override]
31
-	abstract public function send(string $identifier, string $message, array $extra = []): void;
30
+	#[\Override ]
31
+	abstract public function send(string $identifier, string $message, array $extra = [ ]): void;
32 32
 
33
-	#[\Override]
34
-	public function isComplete(array $schema = []): bool {
33
+	#[\Override ]
34
+	public function isComplete(array $schema = [ ]): bool {
35 35
 		if (empty($schema)) {
36 36
 			$schema = static::SCHEMA;
37 37
 		}
38 38
 		$set = $this->appConfig->getKeys(Application::APP_ID);
39
-		$fields = array_column($schema['fields'], 'field');
40
-		$providerId = $schema['id'] ?? $this->getProviderId();
41
-		$fields = array_map(fn ($f) => $providerId . '_' . $f, $fields);
39
+		$fields = array_column($schema[ 'fields' ], 'field');
40
+		$providerId = $schema[ 'id' ] ?? $this->getProviderId();
41
+		$fields = array_map(fn ($f) => $providerId.'_'.$f, $fields);
42 42
 		$intersect = array_intersect($fields, $set);
43 43
 		return count($intersect) === count($fields);
44 44
 	}
45 45
 
46
-	#[\Override]
46
+	#[\Override ]
47 47
 	public function getSettings(): array {
48
-		$settings = [];
49
-		if (isset(static::SCHEMA['instructions'])) {
50
-			$settings['instructions'] = static::SCHEMA['instructions'];
48
+		$settings = [ ];
49
+		if (isset(static::SCHEMA[ 'instructions' ])) {
50
+			$settings[ 'instructions' ] = static::SCHEMA[ 'instructions' ];
51 51
 		}
52
-		$settings['name'] = static::SCHEMA['name'];
52
+		$settings[ 'name' ] = static::SCHEMA[ 'name' ];
53 53
 		return $settings;
54 54
 	}
55 55
 
56
-	#[\Override]
56
+	#[\Override ]
57 57
 	abstract public function cliConfigure(InputInterface $input, OutputInterface $output): int;
58 58
 
59
-	#[\Override]
60
-	public function remove(array $schema = []): void {
59
+	#[\Override ]
60
+	public function remove(array $schema = [ ]): void {
61 61
 		if (empty($schema)) {
62 62
 			$schema = static::SCHEMA;
63 63
 		}
64
-		foreach ($schema['fields'] as $field) {
65
-			$method = 'delete' . $this->toCamel($field['field']);
64
+		foreach ($schema[ 'fields' ] as $field) {
65
+			$method = 'delete'.$this->toCamel($field[ 'field' ]);
66 66
 			$this->{$method}();
67 67
 		}
68 68
 	}
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 		return str_replace(' ', '', ucwords(str_replace('_', ' ', $field)));
72 72
 	}
73 73
 
74
-	#[\Override]
74
+	#[\Override ]
75 75
 	public static function getProviderId(): string {
76 76
 		$id = self::deriveIdFromFqcn(static::class);
77 77
 		if ($id === null) {
78
-			throw new \LogicException('Cannot derive gateway id from FQCN: ' . static::class);
78
+			throw new \LogicException('Cannot derive gateway id from FQCN: '.static::class);
79 79
 		}
80 80
 		return $id;
81 81
 	}
Please login to merge, or discard this patch.
lib/Provider/AProvider.php 1 patch
Spacing   +16 added lines, -16 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,21 +79,21 @@  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
 
86 86
 		try {
87 87
 			$identifier = $this->stateStorage->get($user, $this->getGatewayName())->getIdentifier() ?? '';
88 88
 
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]);
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 ]);
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/Service/SetupService.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,14 +59,14 @@
 block discarded – undo
59 59
 		$verificationNumber = $this->random->generate(6, ISecureRandom::CHAR_DIGITS);
60 60
 		$gateway = $this->gatewayFactory->get($gatewayName);
61 61
 		try {
62
-			$message = match ($gateway->getSettings()['allow_markdown'] ?? false) {
63
-				true => $this->l10n->t('`%s` is your verification code.', [$verificationNumber]),
64
-				default => $this->l10n->t('%s is your verification code.', [$verificationNumber]),
62
+			$message = match ($gateway->getSettings()[ 'allow_markdown' ] ?? false) {
63
+				true => $this->l10n->t('`%s` is your verification code.', [ $verificationNumber ]),
64
+				default => $this->l10n->t('%s is your verification code.', [ $verificationNumber ]),
65 65
 			};
66 66
 			$gateway->send(
67 67
 				$identifier,
68 68
 				$message,
69
-				['code' => $verificationNumber],
69
+				[ 'code' => $verificationNumber ],
70 70
 			);
71 71
 		} catch (MessageTransmissionException $ex) {
72 72
 			throw new VerificationException($ex->getMessage(), $ex->getCode(), $ex);
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 Symfony\Component\Console\Application;
17 17
 
Please login to merge, or discard this patch.
lib/Provider/Channel/Telegram/Gateway.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,17 +31,17 @@  discard block
 block discarded – undo
31 31
 		parent::__construct($appConfig);
32 32
 	}
33 33
 
34
-	#[\Override]
35
-	public function send(string $identifier, string $message, array $extra = []): void {
34
+	#[\Override ]
35
+	public function send(string $identifier, string $message, array $extra = [ ]): void {
36 36
 		$this->getProvider()->send($identifier, $message);
37 37
 	}
38 38
 
39
-	#[\Override]
39
+	#[\Override ]
40 40
 	final public function cliConfigure(InputInterface $input, OutputInterface $output): int {
41 41
 		$namespaces = $this->providerFactory->getFqcnList();
42
-		$schemas = [];
42
+		$schemas = [ ];
43 43
 		foreach ($namespaces as $ns) {
44
-			$schemas[] = $ns::SCHEMA;
44
+			$schemas[ ] = $ns::SCHEMA;
45 45
 		}
46 46
 		$names = array_column($schemas, 'name');
47 47
 
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
 		$choiceQuestion = new ChoiceQuestion('Please choose a Telegram provider:', $names);
50 50
 		$name = $helper->ask($input, $output, $choiceQuestion);
51 51
 		$selectedIndex = array_search($name, $names);
52
-		$schema = $schemas[$selectedIndex];
52
+		$schema = $schemas[ $selectedIndex ];
53 53
 
54
-		$provider = $this->getProvider($namespaces[$selectedIndex]::getProviderId());
54
+		$provider = $this->getProvider($namespaces[ $selectedIndex ]::getProviderId());
55 55
 
56 56
 		$provider->cliConfigure($input, $output);
57 57
 		return 0;
58 58
 	}
59 59
 
60
-	#[\Override]
60
+	#[\Override ]
61 61
 	public function getSettings(): array {
62 62
 		try {
63 63
 			$provider = $this->getProvider();
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 		return $provider::SCHEMA;
68 68
 	}
69 69
 
70
-	#[\Override]
71
-	public function isComplete(array $schema = []): bool {
70
+	#[\Override ]
71
+	public function isComplete(array $schema = [ ]): bool {
72 72
 		if (empty($schema)) {
73 73
 			try {
74 74
 				$provider = $this->getProvider();
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 		return parent::isComplete($schema);
81 81
 	}
82 82
 
83
-	#[\Override]
84
-	public function remove(array $schema = []): void {
83
+	#[\Override ]
84
+	public function remove(array $schema = [ ]): void {
85 85
 		if (empty($schema)) {
86 86
 			$schema = static::SCHEMA;
87 87
 		}
Please login to merge, or discard this patch.
lib/Provider/Channel/Telegram/Provider/Drivers/Client.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 			<p>Enter your full phone number including country code (e.g. +491751234567) as identifier or your Telegram user name preceded by an `@` (e.g. `@myusername`).</p>
40 40
 			HTML,
41 41
 		'fields' => [
42
-			['field' => 'api_id', 'prompt' => 'Please enter your Telegram api_id:'],
43
-			['field' => 'api_hash', 'prompt' => 'Please enter your Telegram api_hash:'],
42
+			[ 'field' => 'api_id', 'prompt' => 'Please enter your Telegram api_id:' ],
43
+			[ 'field' => 'api_hash', 'prompt' => 'Please enter your Telegram api_hash:' ],
44 44
 		],
45 45
 	];
46 46
 	public function __construct(
@@ -51,33 +51,33 @@  discard block
 block discarded – undo
51 51
 	) {
52 52
 	}
53 53
 
54
-	#[\Override]
55
-	public function send(string $identifier, string $message, array $extra = []): void {
54
+	#[\Override ]
55
+	public function send(string $identifier, string $message, array $extra = [ ]): void {
56 56
 		$this->logger->debug("sending telegram message to $identifier, message: $message");
57 57
 
58 58
 		$sessionFile = $this->getSessionDirectory();
59 59
 
60
-		putenv('TELEGRAM_API_ID=' . $this->getApiId());
61
-		putenv('TELEGRAM_API_HASH=' . $this->getApiHash());
60
+		putenv('TELEGRAM_API_ID='.$this->getApiId());
61
+		putenv('TELEGRAM_API_HASH='.$this->getApiHash());
62 62
 
63
-		$path = realpath(__DIR__ . '/ClientCli/Cli.php');
64
-		$cmd = 'php ' . escapeshellarg($path) . ' '
63
+		$path = realpath(__DIR__.'/ClientCli/Cli.php');
64
+		$cmd = 'php '.escapeshellarg($path).' '
65 65
 			. 'telegram:send-message '
66
-			. '--session-directory ' . escapeshellarg($sessionFile)
67
-			. ' --to ' . escapeshellarg($identifier)
68
-			. ' --message ' . escapeshellarg($message);
66
+			. '--session-directory '.escapeshellarg($sessionFile)
67
+			. ' --to '.escapeshellarg($identifier)
68
+			. ' --message '.escapeshellarg($message);
69 69
 
70 70
 		exec($cmd, $output, $returnVar);
71 71
 
72 72
 		if ($returnVar !== 0) {
73
-			$this->logger->error('Error sending Telegram message', ['output' => $output, 'returnVar' => $returnVar]);
73
+			$this->logger->error('Error sending Telegram message', [ 'output' => $output, 'returnVar' => $returnVar ]);
74 74
 			throw new MessageTransmissionException();
75 75
 		}
76 76
 
77 77
 		$this->logger->debug("telegram message to chat $identifier sent");
78 78
 	}
79 79
 
80
-	#[\Override]
80
+	#[\Override ]
81 81
 	public function cliConfigure(InputInterface $input, OutputInterface $output): int {
82 82
 		if (PHP_VERSION_ID < 80200) {
83 83
 			$output->writeln('The Telegram Client API provider requires PHP 8.2 or higher.');
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 		$this->setApiId($apiId);
94 94
 		$this->setApiHash($apiHash);
95 95
 
96
-		putenv('TELEGRAM_API_ID=' . $apiId);
97
-		putenv('TELEGRAM_API_HASH=' . $apiHash);
96
+		putenv('TELEGRAM_API_ID='.$apiId);
97
+		putenv('TELEGRAM_API_HASH='.$apiHash);
98 98
 
99 99
 		$sessionFile = $this->getSessionDirectory();
100 100
 
101
-		$path = realpath(__DIR__ . '/ClientCli/Cli.php');
102
-		$cmd = 'php ' . escapeshellarg($path) . ' '
101
+		$path = realpath(__DIR__.'/ClientCli/Cli.php');
102
+		$cmd = 'php '.escapeshellarg($path).' '
103 103
 			. 'telegram:login '
104
-			. '--session-directory ' . escapeshellarg($sessionFile);
104
+			. '--session-directory '.escapeshellarg($sessionFile);
105 105
 
106 106
 		// This is only to create the client session files.
107 107
 		// The login will be made afterwards.
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		$output->writeln('');
114 114
 		$output->writeln("<comment>$cmd</comment>");
115 115
 		$output->writeln('');
116
-		$output->writeln('Make sure that the user to run the command is the same as the web server user: <info>' . $user['name'] . '</info>.');
116
+		$output->writeln('Make sure that the user to run the command is the same as the web server user: <info>'.$user[ 'name' ].'</info>.');
117 117
 		$output->writeln('');
118 118
 		$output->writeln('Follow the instructions in the command output.');
119 119
 		return 0;
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 		}
129 129
 
130 130
 		$instanceId = $this->config->getSystemValueString('instanceid');
131
-		$appDataFolder = 'appdata_' . $instanceId;
132
-		$dataDirectory = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
133
-		$fullPath = $dataDirectory . '/' . $appDataFolder . '/' . Application::APP_ID . '/session.madeline';
131
+		$appDataFolder = 'appdata_'.$instanceId;
132
+		$dataDirectory = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
133
+		$fullPath = $dataDirectory.'/'.$appDataFolder.'/'.Application::APP_ID.'/session.madeline';
134 134
 
135 135
 		if (is_dir($fullPath) === false) {
136 136
 			$reflection = new \ReflectionClass($folder);
Please login to merge, or discard this patch.