Passed
Pull Request — master (#671)
by Vitor
08:37
created
lib/Provider/Channel/Telegram/Factory.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,38 +15,38 @@
 block discarded – undo
15 15
 
16 16
 class Factory extends AFactory {
17 17
 	/** @var array<string,IProvider> */
18
-	protected array $instances = [];
19
-	#[\Override]
18
+	protected array $instances = [ ];
19
+	#[\Override ]
20 20
 	protected function getPrefix(): string {
21 21
 		return 'OCA\\TwoFactorGateway\\Provider\\Channel\\Telegram\\Provider\\Drivers\\';
22 22
 	}
23 23
 
24
-	#[\Override]
24
+	#[\Override ]
25 25
 	protected function getSuffix(): string {
26 26
 		return '';
27 27
 	}
28 28
 
29
-	#[\Override]
29
+	#[\Override ]
30 30
 	protected function getBaseClass(): string {
31 31
 		return IProvider::class;
32 32
 	}
33 33
 
34
-	#[\Override]
34
+	#[\Override ]
35 35
 	public function isValid(string $fqcn): bool {
36 36
 		return defined("$fqcn::SCHEMA")
37 37
 			&& is_array($fqcn::SCHEMA);
38 38
 	}
39 39
 
40
-	#[\Override]
40
+	#[\Override ]
41 41
 	public function get(string $name): IProvider {
42
-		if (isset($this->instances[$name])) {
43
-			return $this->instances[$name];
42
+		if (isset($this->instances[ $name ])) {
43
+			return $this->instances[ $name ];
44 44
 		}
45 45
 		foreach ($this->getFqcnList() as $fqcn) {
46 46
 			if ($fqcn::getProviderId() === $name) {
47 47
 				$instance = \OCP\Server::get($fqcn);
48 48
 				$instance->setAppConfig(\OCP\Server::get(\OCP\IAppConfig::class));
49
-				$this->instances[$name] = $instance;
49
+				$this->instances[ $name ] = $instance;
50 50
 				return $instance;
51 51
 			}
52 52
 		}
Please login to merge, or discard this patch.
lib/Provider/Channel/Telegram/Gateway.php 1 patch
Spacing   +11 added lines, -11 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,16 +49,16 @@  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, $provider, $schema);
57 57
 		return 0;
58 58
 	}
59 59
 
60
-	#[\Override]
61
-	public function isComplete(array $schema = []): bool {
60
+	#[\Override ]
61
+	public function isComplete(array $schema = [ ]): bool {
62 62
 		if (empty($schema)) {
63 63
 			try {
64 64
 				$provider = $this->getProvider();
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 		return parent::isComplete($schema);
71 71
 	}
72 72
 
73
-	#[\Override]
74
-	public function remove(array $schema = []): void {
73
+	#[\Override ]
74
+	public function remove(array $schema = [ ]): void {
75 75
 		if (empty($schema)) {
76 76
 			$schema = static::SCHEMA;
77 77
 		}
Please login to merge, or discard this patch.
lib/Provider/Channel/Telegram/Provider/Drivers/Client.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 			<p>Enter your Telegram number or username to receive your verification code below.</p>
32 32
 			HTML,
33 33
 		'fields' => [
34
-			['field' => 'bot_token', 'prompt' => 'Please enter your Telegram bot token:'],
34
+			[ 'field' => 'bot_token', 'prompt' => 'Please enter your Telegram bot token:' ],
35 35
 		],
36 36
 	];
37 37
 	public function __construct(
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 	) {
41 41
 	}
42 42
 
43
-	#[\Override]
44
-	public function send(string $identifier, string $message, array $extra = []): void {
43
+	#[\Override ]
44
+	public function send(string $identifier, string $message, array $extra = [ ]): void {
45 45
 		if (empty($message)) {
46
-			$message = $this->l10n->t('`%s` is your Nextcloud verification code.', [$extra['code']]);
46
+			$message = $this->l10n->t('`%s` is your Nextcloud verification code.', [ $extra[ 'code' ] ]);
47 47
 		}
48 48
 		$this->logger->debug("sending telegram message to $identifier, message: $message");
49 49
 		$botToken = $this->getBotToken();
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$this->logger->debug("telegram message to chat $identifier sent");
63 63
 	}
64 64
 
65
-	#[\Override]
65
+	#[\Override ]
66 66
 	public function cliConfigure(InputInterface $input, OutputInterface $output): int {
67 67
 		// if (PHP_VERSION_ID < 80200) {
68 68
 		// 	$output->writeln('The Telegram Client API provider requires PHP 8.2 or higher.');
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		// 	return 1;
71 71
 		// }
72 72
 
73
-		require __DIR__ . '/../../../../../../vendor-bin/telegram-client/vendor/autoload.php';
73
+		require __DIR__.'/../../../../../../vendor-bin/telegram-client/vendor/autoload.php';
74 74
 		// $helper = new QuestionHelper();
75 75
 		// $tokenQuestion = new Question(self::SCHEMA['fields'][0]['prompt'] . ' ');
76 76
 		// $token = $helper->ask($input, $output, $tokenQuestion);
Please login to merge, or discard this patch.
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/AFactory.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 
15 15
 abstract class AFactory {
16 16
 	/** @var array<string,AGateway|AProvider|ISMSProvider|ITelegramProvider> */
17
-	protected array $instances = [];
17
+	protected array $instances = [ ];
18 18
 	/** @var array<string> */
19
-	protected array $fqcn = [];
19
+	protected array $fqcn = [ ];
20 20
 
21 21
 	abstract protected function getPrefix(): string;
22 22
 	abstract protected function getSuffix(): string;
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	/** @return AGateway|AProvider|ISMSProvider|ITelegramProvider */
30 30
 	public function get(string $name): object {
31 31
 		$needle = strtolower($name);
32
-		if (isset($this->instances[$needle])) {
33
-			return $this->instances[$needle];
32
+		if (isset($this->instances[ $needle ])) {
33
+			return $this->instances[ $needle ];
34 34
 		}
35 35
 
36 36
 		foreach ($this->getFqcnList() as $fqcn) {
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 				continue;
40 40
 			}
41 41
 			$instance = \OCP\Server::get($fqcn);
42
-			$this->instances[$needle] = $instance;
42
+			$this->instances[ $needle ] = $instance;
43 43
 			return $instance;
44 44
 		}
45 45
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			return $this->fqcn;
53 53
 		}
54 54
 
55
-		$loader = require __DIR__ . '/../../vendor/autoload.php';
55
+		$loader = require __DIR__.'/../../vendor/autoload.php';
56 56
 		foreach ($loader->getClassMap() as $fqcn => $_) {
57 57
 			$type = $this->typeFrom($fqcn);
58 58
 			if ($type === null) {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 			if (!$this->isValid($fqcn)) {
65 65
 				continue;
66 66
 			}
67
-			$this->fqcn[] = $fqcn;
67
+			$this->fqcn[ ] = $fqcn;
68 68
 		}
69 69
 		return $this->fqcn;
70 70
 	}
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			return null;
80 80
 		}
81 81
 		$type = substr($fqcn, strlen($prefix));
82
-		$type = substr($type, 0, -strlen('\\' . $suffix));
82
+		$type = substr($type, 0, -strlen('\\'.$suffix));
83 83
 		if (strpos($type, '\\') !== false || $type === '') {
84 84
 			return null;
85 85
 		}
Please login to merge, or discard this patch.