Passed
Pull Request — master (#686)
by Vitor
05:00 queued 22s
created
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/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/Command/Remove.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
 class Remove extends Command {
22 22
 	/** @var AGateway[] */
23
-	private array $gateways = [];
23
+	private array $gateways = [ ];
24 24
 
25 25
 	public function __construct(
26 26
 		private Factory $gatewayFactory,
@@ -30,24 +30,24 @@  discard block
 block discarded – undo
30 30
 		$fqcn = $this->gatewayFactory->getFqcnList();
31 31
 		foreach ($fqcn as $fqcn) {
32 32
 			$gateway = $this->gatewayFactory->get($fqcn);
33
-			$this->gateways[$gateway->getSettings()->id] = $gateway;
33
+			$this->gateways[ $gateway->getSettings()->id ] = $gateway;
34 34
 		}
35 35
 
36 36
 		$this->addArgument(
37 37
 			'gateway',
38 38
 			InputArgument::OPTIONAL,
39
-			'The name of the gateway: ' . implode(', ', array_keys($this->gateways))
39
+			'The name of the gateway: '.implode(', ', array_keys($this->gateways))
40 40
 		);
41 41
 	}
42 42
 
43
-	#[\Override]
43
+	#[\Override ]
44 44
 	protected function execute(InputInterface $input, OutputInterface $output) {
45 45
 		$gatewayName = strtolower((string)$input->getArgument('gateway'));
46 46
 		if (!array_key_exists($gatewayName, $this->gateways)) {
47 47
 			$helper = new QuestionHelper();
48 48
 			$choiceQuestion = new ChoiceQuestion('Please choose a provider:', array_keys($this->gateways));
49 49
 			$selected = $helper->ask($input, $output, $choiceQuestion);
50
-			$gateway = $this->gateways[$selected];
50
+			$gateway = $this->gateways[ $selected ];
51 51
 		}
52 52
 
53 53
 		$gateway->remove();
Please login to merge, or discard this patch.
lib/Command/Test.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
 		parent::__construct('twofactorauth:gateway:test');
26 26
 
27 27
 		$fqcn = $this->gatewayFactory->getFqcnList();
28
-		$gateways = [];
28
+		$gateways = [ ];
29 29
 		foreach ($fqcn as $fqcn) {
30 30
 			$gateway = $this->gatewayFactory->get($fqcn);
31
-			$gateways[$gateway->getSettings()->id] = $gateway;
31
+			$gateways[ $gateway->getSettings()->id ] = $gateway;
32 32
 		}
33 33
 
34 34
 		$this->addArgument(
35 35
 			'gateway',
36 36
 			InputArgument::REQUIRED,
37
-			'The name of the gateway: ' . implode(', ', array_keys($gateways))
37
+			'The name of the gateway: '.implode(', ', array_keys($gateways))
38 38
 		);
39 39
 		$this->addArgument(
40 40
 			'identifier',
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		);
44 44
 	}
45 45
 
46
-	#[\Override]
46
+	#[\Override ]
47 47
 	protected function execute(InputInterface $input, OutputInterface $output) {
48 48
 		$gatewayName = $input->getArgument('gateway');
49 49
 		$identifier = $input->getArgument('identifier');
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			return 1;
56 56
 		}
57 57
 
58
-		$gateway->send($identifier, 'Test', ['code' => '123456']);
58
+		$gateway->send($identifier, 'Test', [ 'code' => '123456' ]);
59 59
 		return 0;
60 60
 	}
61 61
 }
Please login to merge, or discard this patch.
lib/Command/Configure.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 class Configure extends Command {
23 23
 	/** @var AGateway[] */
24
-	private array $gateways = [];
24
+	private array $gateways = [ ];
25 25
 
26 26
 	public function __construct(
27 27
 		private Factory $gatewayFactory,
@@ -31,24 +31,24 @@  discard block
 block discarded – undo
31 31
 		$fqcn = $this->gatewayFactory->getFqcnList();
32 32
 		foreach ($fqcn as $fqcn) {
33 33
 			$gateway = $this->gatewayFactory->get($fqcn);
34
-			$this->gateways[$gateway->getSettings()->id] = $gateway;
34
+			$this->gateways[ $gateway->getSettings()->id ] = $gateway;
35 35
 		}
36 36
 
37 37
 		$this->addArgument(
38 38
 			'gateway',
39 39
 			InputArgument::OPTIONAL,
40
-			'The name of the gateway: ' . implode(', ', array_keys($this->gateways))
40
+			'The name of the gateway: '.implode(', ', array_keys($this->gateways))
41 41
 		);
42 42
 	}
43 43
 
44
-	#[\Override]
44
+	#[\Override ]
45 45
 	protected function execute(InputInterface $input, OutputInterface $output) {
46 46
 		$gatewayName = strtolower((string)$input->getArgument('gateway'));
47 47
 		if (!array_key_exists($gatewayName, $this->gateways)) {
48 48
 			$helper = new QuestionHelper();
49 49
 			$choiceQuestion = new ChoiceQuestion('Please choose a provider:', array_keys($this->gateways));
50 50
 			$selectedIndex = $helper->ask($input, $output, $choiceQuestion);
51
-			$gateway = $this->gateways[array_keys($this->gateways)[$selectedIndex]];
51
+			$gateway = $this->gateways[ array_keys($this->gateways)[ $selectedIndex ] ];
52 52
 		}
53 53
 
54 54
 		try {
Please login to merge, or discard this patch.
lib/Provider/Channel/SMS/Factory.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,37 +16,37 @@
 block discarded – undo
16 16
 /** @extends AFactory<AProvider> */
17 17
 class Factory extends AFactory {
18 18
 	/** @var array<AProvider> */
19
-	private array $instancesByFqcn = [];
20
-	#[\Override]
19
+	private array $instancesByFqcn = [ ];
20
+	#[\Override ]
21 21
 	protected function getPrefix(): string {
22 22
 		return 'OCA\\TwoFactorGateway\\Provider\\Channel\\SMS\\Provider\\Drivers\\';
23 23
 	}
24 24
 
25
-	#[\Override]
25
+	#[\Override ]
26 26
 	protected function getSuffix(): string {
27 27
 		return '';
28 28
 	}
29 29
 
30
-	#[\Override]
30
+	#[\Override ]
31 31
 	protected function getBaseClass(): string {
32 32
 		return AProvider::class;
33 33
 	}
34 34
 
35
-	#[\Override]
35
+	#[\Override ]
36 36
 	public function get(string $name): object {
37
-		if (isset($this->instancesByFqcn[$name])) {
38
-			return $this->instancesByFqcn[$name];
37
+		if (isset($this->instancesByFqcn[ $name ])) {
38
+			return $this->instancesByFqcn[ $name ];
39 39
 		}
40
-		if (isset($this->instances[$name])) {
41
-			return $this->instances[$name];
40
+		if (isset($this->instances[ $name ])) {
41
+			return $this->instances[ $name ];
42 42
 		}
43 43
 		foreach ($this->getFqcnList() as $fqcn) {
44 44
 			$instance = \OCP\Server::get($fqcn);
45 45
 			$settings = $instance->getSettings();
46 46
 			if ($fqcn === $name || $settings->id === $name) {
47 47
 				$instance->setAppConfig(\OCP\Server::get(\OCP\IAppConfig::class));
48
-				$this->instances[$settings->id] = $instance;
49
-				$this->instancesByFqcn[$fqcn] = $instance;
48
+				$this->instances[ $settings->id ] = $instance;
49
+				$this->instancesByFqcn[ $fqcn ] = $instance;
50 50
 				return $instance;
51 51
 			}
52 52
 		}
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[] = $provider;
45
-			$names[] = $provider->getSettings()->name;
44
+			$providers[ ] = $provider;
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
 		foreach ($this->smsProviderFactory->getFqcnList() as $fqcn) {
103 103
 			$provider = $this->smsProviderFactory->get($fqcn);
Please login to merge, or discard this patch.