Passed
Pull Request — master (#686)
by Vitor
04:24
created
lib/Provider/Channel/Telegram/Provider/Drivers/Bot.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			<p>Enter this ID to receive your verification code below.</p>
38 38
 			HTML,
39 39
 		'fields' => [
40
-			['field' => 'bot_token', 'prompt' => 'Please enter your Telegram bot token:'],
40
+			[ 'field' => 'bot_token', 'prompt' => 'Please enter your Telegram bot token:' ],
41 41
 		],
42 42
 	];
43 43
 	public function __construct(
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 	) {
47 47
 	}
48 48
 
49
-	#[\Override]
50
-	public function send(string $identifier, string $message, array $extra = []): void {
49
+	#[\Override ]
50
+	public function send(string $identifier, string $message, array $extra = [ ]): void {
51 51
 		if (empty($message)) {
52
-			$message = $this->l10n->t('`%s` is your Nextcloud verification code.', [$extra['code']]);
52
+			$message = $this->l10n->t('`%s` is your Nextcloud verification code.', [ $extra[ 'code' ] ]);
53 53
 		}
54 54
 		$this->logger->debug("sending telegram message to $identifier, message: $message");
55 55
 		$botToken = $this->getBotToken();
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 		$this->logger->debug("telegram message to chat $identifier sent");
69 69
 	}
70 70
 
71
-	#[\Override]
71
+	#[\Override ]
72 72
 	public function cliConfigure(InputInterface $input, OutputInterface $output): int {
73 73
 		$helper = new QuestionHelper();
74
-		$tokenQuestion = new Question(self::SCHEMA['fields'][0]['prompt'] . ' ');
74
+		$tokenQuestion = new Question(self::SCHEMA[ 'fields' ][ 0 ][ 'prompt' ].' ');
75 75
 		$token = $helper->ask($input, $output, $tokenQuestion);
76 76
 		$this->setBotToken($token);
77 77
 		$output->writeln("Using $token.");
Please login to merge, or discard this patch.
lib/Provider/Channel/Telegram/Provider/IProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 use Symfony\Component\Console\Output\OutputInterface;
16 16
 
17 17
 interface IProvider {
18
-	public const SCHEMA = [];
18
+	public const SCHEMA = [ ];
19 19
 
20 20
 	/**
21 21
 	 * @param string $identifier
Please login to merge, or discard this patch.
lib/Provider/Channel/Telegram/Provider/AProvider.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,32 +22,32 @@
 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 static function idOverride(): ?string {
35 35
 		return null;
36 36
 	}
37 37
 
38
-	#[\Override]
38
+	#[\Override ]
39 39
 	public static function getProviderId(): string {
40
-		if (static::SCHEMA['id'] ?? null) {
41
-			return static::SCHEMA['id'];
40
+		if (static::SCHEMA[ 'id' ] ?? null) {
41
+			return static::SCHEMA[ 'id' ];
42 42
 		}
43 43
 		$id = self::getIdFromProviderFqcn(static::class);
44 44
 		if ($id === null) {
45
-			throw new \LogicException('Cannot derive gateway id from FQCN: ' . static::class);
45
+			throw new \LogicException('Cannot derive gateway id from FQCN: '.static::class);
46 46
 		}
47 47
 		return $id;
48 48
 	}
49 49
 
50
-	#[\Override]
50
+	#[\Override ]
51 51
 	abstract public function cliConfigure(InputInterface $input, OutputInterface $output): int;
52 52
 
53 53
 	private static function getIdFromProviderFqcn(string $fqcn): ?string {
Please login to merge, or discard this patch.
lib/Provider/Channel/Telegram/Provider/Drivers/ClientCli/Login.php 1 patch
Spacing   +3 added lines, -3 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:login', description: 'Login into Telegram using the Client API')]
21
+#[AsCommand(name: 'telegram:login', description: 'Login into Telegram using the Client API') ]
22 22
 class Login extends Command {
23 23
 
24 24
 	protected function configure(): void {
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		try {
47 47
 			$settings = (new Settings())
48 48
 				->setAppInfo($appInfo)
49
-				->setLogger((new Logger())->setExtra($sessionDirectory . '/MadelineProto.log'));
49
+				->setLogger((new Logger())->setExtra($sessionDirectory.'/MadelineProto.log'));
50 50
 
51 51
 			$api = new API($sessionDirectory, $settings);
52 52
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
 			return Command::SUCCESS;
64 64
 		} catch (\Throwable $e) {
65
-			$output->writeln('<error>Error: ' . $e->getMessage() . '</error>');
65
+			$output->writeln('<error>Error: '.$e->getMessage().'</error>');
66 66
 			return Command::FAILURE;
67 67
 		}
68 68
 	}
Please login to merge, or discard this patch.
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/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/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.