@@ -43,7 +43,7 @@ |
||
| 43 | 43 | ); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - #[\Override] |
|
| 46 | + #[\Override ] |
|
| 47 | 47 | public function send(string $identifier, string $message) { |
| 48 | 48 | $apiKey = $this->getApiKey(); |
| 49 | 49 | try { |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | ); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - #[\Override] |
|
| 54 | + #[\Override ] |
|
| 55 | 55 | public function send(string $identifier, string $message) { |
| 56 | 56 | try { |
| 57 | 57 | $from = $this->getFrom(); |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | ); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - #[\Override] |
|
| 58 | + #[\Override ] |
|
| 59 | 59 | public function send(string $identifier, string $message) { |
| 60 | 60 | $user = $this->getUsername(); |
| 61 | 61 | $password = $this->getPassword(); |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | ); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - #[\Override] |
|
| 59 | + #[\Override ] |
|
| 60 | 60 | public function send(string $identifier, string $message) { |
| 61 | 61 | try { |
| 62 | 62 | $response = $this->client->get(vsprintf('https://api.clickatell.com/http/sendmsg?user=%s&password=%s&api_id=%u&to=%s&text=%s', [ |
@@ -49,20 +49,20 @@ |
||
| 49 | 49 | ); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - #[\Override] |
|
| 52 | + #[\Override ] |
|
| 53 | 53 | public function send(string $identifier, string $message) { |
| 54 | 54 | $user = $this->getUser(); |
| 55 | 55 | $password = $this->getPassword(); |
| 56 | 56 | try { |
| 57 | 57 | $this->client->post('https://api.websms.com/rest/smsmessaging/text', [ |
| 58 | 58 | 'headers' => [ |
| 59 | - 'Authorization' => 'Basic ' . base64_encode("$user:$password"), |
|
| 59 | + 'Authorization' => 'Basic '.base64_encode("$user:$password"), |
|
| 60 | 60 | 'Content-Type' => 'application/json', |
| 61 | 61 | ], |
| 62 | 62 | 'json' => [ |
| 63 | 63 | 'messageContent' => $message, |
| 64 | 64 | 'test' => false, |
| 65 | - 'recipientAddressList' => [$identifier], |
|
| 65 | + 'recipientAddressList' => [ $identifier ], |
|
| 66 | 66 | ], |
| 67 | 67 | ]); |
| 68 | 68 | } catch (Exception $ex) { |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @throws MessageTransmissionException |
| 26 | 26 | */ |
| 27 | - public function send(string $identifier, string $message, array $extra = []): void; |
|
| 27 | + public function send(string $identifier, string $message, array $extra = [ ]): void; |
|
| 28 | 28 | |
| 29 | 29 | public function isComplete(?Settings $settings = null): bool; |
| 30 | 30 | |
@@ -60,13 +60,13 @@ |
||
| 60 | 60 | $gateway = $this->gatewayFactory->get($gatewayName); |
| 61 | 61 | try { |
| 62 | 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]), |
|
| 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); |
@@ -22,11 +22,11 @@ |
||
| 22 | 22 | * |
| 23 | 23 | * @var FieldDefinition[] |
| 24 | 24 | */ |
| 25 | - public array $fields = [], |
|
| 25 | + public array $fields = [ ], |
|
| 26 | 26 | ) { |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - #[\Override] |
|
| 29 | + #[\Override ] |
|
| 30 | 30 | public function jsonSerialize(): mixed { |
| 31 | 31 | return [ |
| 32 | 32 | 'name' => $this->name, |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | parent::__construct($appConfig); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - #[\Override] |
|
| 45 | + #[\Override ] |
|
| 46 | 46 | public function createSettings(): Settings { |
| 47 | 47 | return new Settings( |
| 48 | 48 | name: 'Signal', |
@@ -61,20 +61,20 @@ discard block |
||
| 61 | 61 | ); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - #[\Override] |
|
| 65 | - public function send(string $identifier, string $message, array $extra = []): void { |
|
| 64 | + #[\Override ] |
|
| 65 | + public function send(string $identifier, string $message, array $extra = [ ]): void { |
|
| 66 | 66 | $client = $this->clientService->newClient(); |
| 67 | 67 | // determine type of gateway |
| 68 | 68 | |
| 69 | 69 | // test for native signal-cli JSON RPC. |
| 70 | 70 | $response = $client->post( |
| 71 | - $this->getUrl() . '/api/v1/rpc', |
|
| 71 | + $this->getUrl().'/api/v1/rpc', |
|
| 72 | 72 | [ |
| 73 | 73 | 'http_errors' => false, |
| 74 | 74 | 'json' => [ |
| 75 | 75 | 'jsonrpc' => '2.0', |
| 76 | 76 | 'method' => 'version', |
| 77 | - 'id' => 'version_' . $this->timeFactory->getTime(), |
|
| 77 | + 'id' => 'version_'.$this->timeFactory->getTime(), |
|
| 78 | 78 | ], |
| 79 | 79 | ]); |
| 80 | 80 | if ($response->getStatusCode() === 200 || $response->getStatusCode() === 201) { |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | 'account' => $this->getAccount(), // mandatory for native RPC API |
| 91 | 91 | ]; |
| 92 | 92 | $response = $response = $client->post( |
| 93 | - $this->getUrl() . '/api/v1/rpc', |
|
| 93 | + $this->getUrl().'/api/v1/rpc', |
|
| 94 | 94 | [ |
| 95 | 95 | 'json' => [ |
| 96 | 96 | 'jsonrpc' => '2.0', |
| 97 | 97 | 'method' => 'send', |
| 98 | - 'id' => 'code_' . $this->timeFactory->getTime(), |
|
| 98 | + 'id' => 'code_'.$this->timeFactory->getTime(), |
|
| 99 | 99 | 'params' => $params, |
| 100 | 100 | ], |
| 101 | 101 | ]); |
@@ -103,12 +103,12 @@ discard block |
||
| 103 | 103 | $json = json_decode($body, true); |
| 104 | 104 | $statusCode = $response->getStatusCode(); |
| 105 | 105 | // The 201 "created" is probably a bug. |
| 106 | - if ($statusCode < 200 || $statusCode >= 300 || is_null($json) || !is_array($json) || ($json['jsonrpc'] ?? null) != '2.0' || !isset($json['result']['timestamp'])) { |
|
| 106 | + if ($statusCode < 200 || $statusCode >= 300 || is_null($json) || !is_array($json) || ($json[ 'jsonrpc' ] ?? null) != '2.0' || !isset($json[ 'result' ][ 'timestamp' ])) { |
|
| 107 | 107 | throw new MessageTransmissionException("error reported by Signal gateway, status=$statusCode, body=$body}"); |
| 108 | 108 | } |
| 109 | 109 | } else { |
| 110 | 110 | // Try gateway in the style of https://gitlab.com/morph027/signal-cli-dbus-rest-api |
| 111 | - $response = $client->get($this->getUrl() . '/v1/about'); |
|
| 111 | + $response = $client->get($this->getUrl().'/v1/about'); |
|
| 112 | 112 | if ($response->getStatusCode() === 200) { |
| 113 | 113 | // Not so "ńew style" gateway, see |
| 114 | 114 | // https://gitlab.com/morph027/signal-cli-dbus-rest-api |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | // https://github.com/bbernhard/signal-cli-rest-api |
| 117 | 117 | $body = $response->getBody(); |
| 118 | 118 | $json = json_decode($body, true); |
| 119 | - $versions = $json['versions'] ?? []; |
|
| 119 | + $versions = $json[ 'versions' ] ?? [ ]; |
|
| 120 | 120 | if (is_array($versions) && in_array('v2', $versions)) { |
| 121 | 121 | $json = [ |
| 122 | 122 | 'recipients' => $identifier, |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | ]; |
| 125 | 125 | $account = $this->getAccount(); |
| 126 | 126 | if ($account != self::ACCOUNT_UNNECESSARY) { |
| 127 | - $json['account'] = $account; |
|
| 127 | + $json[ 'account' ] = $account; |
|
| 128 | 128 | } |
| 129 | 129 | $response = $client->post( |
| 130 | - $this->getUrl() . '/v2/send', |
|
| 130 | + $this->getUrl().'/v2/send', |
|
| 131 | 131 | [ |
| 132 | 132 | 'json' => $json, |
| 133 | 133 | ] |
| 134 | 134 | ); |
| 135 | 135 | } else { |
| 136 | 136 | $response = $client->post( |
| 137 | - $this->getUrl() . '/v1/send/' . $identifier, |
|
| 137 | + $this->getUrl().'/v1/send/'.$identifier, |
|
| 138 | 138 | [ |
| 139 | 139 | 'json' => [ 'message' => $message ], |
| 140 | 140 | ] |
@@ -143,13 +143,13 @@ discard block |
||
| 143 | 143 | $body = (string)$response->getBody(); |
| 144 | 144 | $json = json_decode($body, true); |
| 145 | 145 | $status = $response->getStatusCode(); |
| 146 | - if ($status !== 201 || is_null($json) || !is_array($json) || !isset($json['timestamp'])) { |
|
| 146 | + if ($status !== 201 || is_null($json) || !is_array($json) || !isset($json[ 'timestamp' ])) { |
|
| 147 | 147 | throw new MessageTransmissionException("error reported by Signal gateway, status=$status, body=$body}"); |
| 148 | 148 | } |
| 149 | 149 | } else { |
| 150 | 150 | // Try old deprecated gateway https://gitlab.com/morph027/signal-web-gateway |
| 151 | 151 | $response = $client->post( |
| 152 | - $this->getUrl() . '/v1/send/' . $identifier, |
|
| 152 | + $this->getUrl().'/v1/send/'.$identifier, |
|
| 153 | 153 | [ |
| 154 | 154 | 'body' => [ |
| 155 | 155 | 'to' => $identifier, |
@@ -162,24 +162,24 @@ discard block |
||
| 162 | 162 | $json = json_decode($body, true); |
| 163 | 163 | |
| 164 | 164 | $status = $response->getStatusCode(); |
| 165 | - if ($status !== 200 || is_null($json) || !is_array($json) || !isset($json['success']) || $json['success'] !== true) { |
|
| 165 | + if ($status !== 200 || is_null($json) || !is_array($json) || !isset($json[ 'success' ]) || $json[ 'success' ] !== true) { |
|
| 166 | 166 | throw new MessageTransmissionException("error reported by Signal gateway, status=$status, body=$body}"); |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - #[\Override] |
|
| 172 | + #[\Override ] |
|
| 173 | 173 | public function cliConfigure(InputInterface $input, OutputInterface $output): int { |
| 174 | 174 | $settings = $this->getSettings(); |
| 175 | 175 | $helper = new QuestionHelper(); |
| 176 | - $urlQuestion = new Question($settings->fields[0]->prompt, $settings->fields[0]->default); |
|
| 176 | + $urlQuestion = new Question($settings->fields[ 0 ]->prompt, $settings->fields[ 0 ]->default); |
|
| 177 | 177 | $url = $helper->ask($input, $output, $urlQuestion); |
| 178 | 178 | $output->writeln("Using $url."); |
| 179 | 179 | |
| 180 | 180 | $this->setUrl($url); |
| 181 | 181 | |
| 182 | - $accountQuestion = new Question($settings->fields[1]->prompt, $settings->fields[1]->default); |
|
| 182 | + $accountQuestion = new Question($settings->fields[ 1 ]->prompt, $settings->fields[ 1 ]->default); |
|
| 183 | 183 | $account = $helper->ask($input, $output, $accountQuestion); |
| 184 | 184 | if ($account == '') { |
| 185 | 185 | $account = self::ACCOUNT_UNNECESSARY; |