@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | use Symfony\Component\Console\Question\ChoiceQuestion; |
| 21 | 21 | |
| 22 | 22 | class Configure extends Command { |
| 23 | - private array $ids = []; |
|
| 23 | + private array $ids = [ ]; |
|
| 24 | 24 | |
| 25 | 25 | public function __construct( |
| 26 | 26 | private Factory $gatewayFactory, |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $fqcn = $this->gatewayFactory->getFqcnList(); |
| 31 | 31 | foreach ($fqcn as $fqcn) { |
| 32 | - $this->ids[] = $fqcn::getProviderId(); |
|
| 32 | + $this->ids[ ] = $fqcn::getProviderId(); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $this->addArgument( |
| 36 | 36 | 'gateway', |
| 37 | 37 | InputArgument::OPTIONAL, |
| 38 | - 'The name of the gateway: ' . implode(', ', $this->ids) |
|
| 38 | + 'The name of the gateway: '.implode(', ', $this->ids) |
|
| 39 | 39 | ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - #[\Override] |
|
| 42 | + #[\Override ] |
|
| 43 | 43 | protected function execute(InputInterface $input, OutputInterface $output) { |
| 44 | 44 | $gatewayName = strtolower((string)$input->getArgument('gateway')); |
| 45 | 45 | if (!in_array($gatewayName, $this->ids, true)) { |
@@ -43,17 +43,17 @@ discard block |
||
| 43 | 43 | * 400: User not found |
| 44 | 44 | * 503: Gateway wasn't configured yed |
| 45 | 45 | */ |
| 46 | - #[NoAdminRequired] |
|
| 47 | - #[ApiRoute(verb: 'GET', url: '/settings/{gateway}/verification')] |
|
| 46 | + #[NoAdminRequired ] |
|
| 47 | + #[ApiRoute(verb: 'GET', url: '/settings/{gateway}/verification') ] |
|
| 48 | 48 | public function getVerificationState(string $gateway): JSONResponse { |
| 49 | 49 | $user = $this->userSession->getUser(); |
| 50 | 50 | |
| 51 | 51 | if (is_null($user)) { |
| 52 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
| 52 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | if (!$this->gatewayFactory->get($gateway)->isComplete()) { |
| 56 | - return new JSONResponse([], Http::STATUS_SERVICE_UNAVAILABLE); |
|
| 56 | + return new JSONResponse([ ], Http::STATUS_SERVICE_UNAVAILABLE); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return new JSONResponse($this->setup->getState($user, $gateway)->jsonSerialize()); |
@@ -70,19 +70,19 @@ discard block |
||
| 70 | 70 | * 200: OK |
| 71 | 71 | * 400: User not found |
| 72 | 72 | */ |
| 73 | - #[NoAdminRequired] |
|
| 74 | - #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/start')] |
|
| 73 | + #[NoAdminRequired ] |
|
| 74 | + #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/start') ] |
|
| 75 | 75 | public function startVerification(string $gateway, string $identifier): JSONResponse { |
| 76 | 76 | $user = $this->userSession->getUser(); |
| 77 | 77 | |
| 78 | 78 | if (is_null($user)) { |
| 79 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
| 79 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | try { |
| 83 | 83 | $state = $this->setup->startSetup($user, $gateway, $identifier); |
| 84 | 84 | } catch (VerificationException $e) { |
| 85 | - return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
|
| 85 | + return new JSONResponse([ 'message' => $e->getMessage() ], Http::STATUS_BAD_REQUEST); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | return new JSONResponse([ |
@@ -101,22 +101,22 @@ discard block |
||
| 101 | 101 | * 200: OK |
| 102 | 102 | * 400: User not found |
| 103 | 103 | */ |
| 104 | - #[NoAdminRequired] |
|
| 105 | - #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/finish')] |
|
| 104 | + #[NoAdminRequired ] |
|
| 105 | + #[ApiRoute(verb: 'POST', url: '/settings/{gateway}/verification/finish') ] |
|
| 106 | 106 | public function finishVerification(string $gateway, string $verificationCode): JSONResponse { |
| 107 | 107 | $user = $this->userSession->getUser(); |
| 108 | 108 | |
| 109 | 109 | if (is_null($user)) { |
| 110 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
| 110 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | try { |
| 114 | 114 | $this->setup->finishSetup($user, $gateway, $verificationCode); |
| 115 | 115 | } catch (VerificationException) { |
| 116 | - return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
|
| 116 | + return new JSONResponse([ ], Http::STATUS_BAD_REQUEST); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - return new JSONResponse([]); |
|
| 119 | + return new JSONResponse([ ]); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -128,13 +128,13 @@ discard block |
||
| 128 | 128 | * 200: OK |
| 129 | 129 | * 400: User not found |
| 130 | 130 | */ |
| 131 | - #[NoAdminRequired] |
|
| 132 | - #[ApiRoute(verb: 'DELETE', url: '/settings/{gateway}/verification')] |
|
| 131 | + #[NoAdminRequired ] |
|
| 132 | + #[ApiRoute(verb: 'DELETE', url: '/settings/{gateway}/verification') ] |
|
| 133 | 133 | public function revokeVerification(string $gateway): JSONResponse { |
| 134 | 134 | $user = $this->userSession->getUser(); |
| 135 | 135 | |
| 136 | 136 | if (is_null($user)) { |
| 137 | - return new JSONResponse(['message' => 'User not found'], Http::STATUS_BAD_REQUEST); |
|
| 137 | + return new JSONResponse([ 'message' => 'User not found' ], Http::STATUS_BAD_REQUEST); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | return new JSONResponse($this->setup->disable($user, $gateway)); |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | ) { |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - #[\Override] |
|
| 25 | + #[\Override ] |
|
| 26 | 26 | public function getBody(): ITemplate { |
| 27 | 27 | $template = Server::get(ITemplateManager::class)->getTemplate('twofactor_gateway', 'personal_settings'); |
| 28 | 28 | $template->assign('gateway', $this->gateway); |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | private function buildConfigKey(string $gatewayName, string $key): string { |
| 30 | - return $gatewayName . "_$key"; |
|
| 30 | + return $gatewayName."_$key"; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | private function getUserValue(IUser $user, string $gatewayName, string $key, string $default = ''): string { |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * twofactorgateway?: TwoFactorGatewayCapabilities, |
| 30 | 30 | * } |
| 31 | 31 | */ |
| 32 | - #[Override] |
|
| 32 | + #[Override ] |
|
| 33 | 33 | public function getCapabilities(): array { |
| 34 | 34 | $capabilities = [ |
| 35 | 35 | 'features' => self::FEATURES, |
@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | ) { |
| 26 | 26 | parent::__construct('twofactorauth:gateway:test'); |
| 27 | 27 | |
| 28 | - $ids = []; |
|
| 28 | + $ids = [ ]; |
|
| 29 | 29 | $fqcn = $this->gatewayFactory->getFqcnList(); |
| 30 | 30 | foreach ($fqcn as $fqcn) { |
| 31 | - $ids[] = $fqcn::getProviderId(); |
|
| 31 | + $ids[ ] = $fqcn::getProviderId(); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $this->addArgument( |
| 35 | 35 | 'gateway', |
| 36 | 36 | InputArgument::REQUIRED, |
| 37 | - 'The name of the gateway: ' . implode(', ', $ids) |
|
| 37 | + 'The name of the gateway: '.implode(', ', $ids) |
|
| 38 | 38 | ); |
| 39 | 39 | $this->addArgument( |
| 40 | 40 | 'identifier', |
@@ -43,7 +43,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -15,7 +15,7 @@ |
||
| 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 |
@@ -18,7 +18,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |