@@ -37,7 +37,7 @@ discard block |
||
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 |
||
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,7 +79,7 @@ discard block |
||
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 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $this->l10n->t('%s is your Nextcloud authentication code', [ |
92 | 92 | $secret |
93 | 93 | ]), |
94 | - ['code' => $secret], |
|
94 | + [ 'code' => $secret ], |
|
95 | 95 | ); |
96 | 96 | } catch (MessageTransmissionException) { |
97 | 97 | return $this->templateManager->getTemplate('twofactor_gateway', 'error'); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | return $tmpl; |
103 | 103 | } |
104 | 104 | |
105 | - #[\Override] |
|
105 | + #[\Override ] |
|
106 | 106 | public function verifyChallenge(IUser $user, string $challenge): bool { |
107 | 107 | $valid = $this->session->exists($this->getSessionKey()) |
108 | 108 | && $this->session->get($this->getSessionKey()) === $challenge; |
@@ -114,31 +114,31 @@ discard block |
||
114 | 114 | return $valid; |
115 | 115 | } |
116 | 116 | |
117 | - #[\Override] |
|
117 | + #[\Override ] |
|
118 | 118 | public function isTwoFactorAuthEnabledForUser(IUser $user): bool { |
119 | 119 | return $this->stateStorage->get($user, $this->getGatewayName())->getState() === StateStorage::STATE_ENABLED; |
120 | 120 | } |
121 | 121 | |
122 | - #[\Override] |
|
122 | + #[\Override ] |
|
123 | 123 | public function getPersonalSettings(IUser $user): IPersonalProviderSettings { |
124 | - $this->initialState->provideInitialState('settings-' . $this->gateway->getProviderId(), $this->gateway->getSettings()); |
|
124 | + $this->initialState->provideInitialState('settings-'.$this->gateway->getProviderId(), $this->gateway->getSettings()); |
|
125 | 125 | return new PersonalSettings( |
126 | 126 | $this->getGatewayName(), |
127 | 127 | $this->gateway->isComplete(), |
128 | 128 | ); |
129 | 129 | } |
130 | 130 | |
131 | - #[\Override] |
|
131 | + #[\Override ] |
|
132 | 132 | public function getLightIcon(): String { |
133 | 133 | return Server::get(IURLGenerator::class)->imagePath(Application::APP_ID, 'app.svg'); |
134 | 134 | } |
135 | 135 | |
136 | - #[\Override] |
|
136 | + #[\Override ] |
|
137 | 137 | public function getDarkIcon(): String { |
138 | 138 | return Server::get(IURLGenerator::class)->imagePath(Application::APP_ID, 'app-dark.svg'); |
139 | 139 | } |
140 | 140 | |
141 | - #[\Override] |
|
141 | + #[\Override ] |
|
142 | 142 | public function disableFor(IUser $user) { |
143 | 143 | $state = $this->stateStorage->get($user, $this->getGatewayName()); |
144 | 144 | if ($state->getState() === StateStorage::STATE_ENABLED) { |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | 'id' => 'clickatell_central', |
29 | 29 | 'name' => 'Clickatell Central', |
30 | 30 | 'fields' => [ |
31 | - ['field' => 'api', 'prompt' => 'Please enter your central.clickatell.com API-ID:'], |
|
32 | - ['field' => 'user', 'prompt' => 'Please enter your central.clickatell.com username:'], |
|
33 | - ['field' => 'password', 'prompt' => 'Please enter your central.clickatell.com password:'], |
|
31 | + [ 'field' => 'api', 'prompt' => 'Please enter your central.clickatell.com API-ID:' ], |
|
32 | + [ 'field' => 'user', 'prompt' => 'Please enter your central.clickatell.com username:' ], |
|
33 | + [ 'field' => 'password', 'prompt' => 'Please enter your central.clickatell.com password:' ], |
|
34 | 34 | ], |
35 | 35 | ]; |
36 | 36 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $this->client = $clientService->newClient(); |
43 | 43 | } |
44 | 44 | |
45 | - #[\Override] |
|
45 | + #[\Override ] |
|
46 | 46 | public function send(string $identifier, string $message) { |
47 | 47 | try { |
48 | 48 | $response = $this->client->get(vsprintf('https://api.clickatell.com/http/sendmsg?user=%s&password=%s&api_id=%u&to=%s&text=%s', [ |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | 'id' => 'huawei_e3531', |
25 | 25 | 'name' => 'Huawei E3531', |
26 | 26 | 'fields' => [ |
27 | - ['field' => 'api', 'prompt' => 'Please enter the base URL of the Huawei E3531 stick: ', 'default' => 'http://192.168.8.1/api'], |
|
27 | + [ 'field' => 'api', 'prompt' => 'Please enter the base URL of the Huawei E3531 stick: ', 'default' => 'http://192.168.8.1/api' ], |
|
28 | 28 | ], |
29 | 29 | ]; |
30 | 30 | private IClient $client; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $this->client = $clientService->newClient(); |
36 | 36 | } |
37 | 37 | |
38 | - #[\Override] |
|
38 | + #[\Override ] |
|
39 | 39 | public function send(string $identifier, string $message) { |
40 | 40 | $url = $this->getApi(); |
41 | 41 |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | 'id' => 'clickatell_portal', |
28 | 28 | 'name' => 'Clickatell Portal', |
29 | 29 | 'fields' => [ |
30 | - ['field' => 'apikey', 'prompt' => 'Please enter your portal.clickatell.com API-Key:'], |
|
31 | - ['field' => 'from', 'prompt' => 'Please enter your sender number for two-way messaging (empty = one-way): ', 'optional' => true], |
|
30 | + [ 'field' => 'apikey', 'prompt' => 'Please enter your portal.clickatell.com API-Key:' ], |
|
31 | + [ 'field' => 'from', 'prompt' => 'Please enter your sender number for two-way messaging (empty = one-way): ', 'optional' => true ], |
|
32 | 32 | ], |
33 | 33 | ]; |
34 | 34 | private IClient $client; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $this->client = $clientService->newClient(); |
40 | 40 | } |
41 | 41 | |
42 | - #[\Override] |
|
42 | + #[\Override ] |
|
43 | 43 | public function send(string $identifier, string $message) { |
44 | 44 | try { |
45 | 45 | $from = $this->getFrom(); |
@@ -33,17 +33,17 @@ discard block |
||
33 | 33 | parent::__construct($appConfig); |
34 | 34 | } |
35 | 35 | |
36 | - #[\Override] |
|
37 | - public function send(IUser $user, string $identifier, string $message, array $extra = []): void { |
|
36 | + #[\Override ] |
|
37 | + public function send(IUser $user, string $identifier, string $message, array $extra = [ ]): void { |
|
38 | 38 | $this->getProvider()->send($identifier, $message); |
39 | 39 | } |
40 | 40 | |
41 | - #[\Override] |
|
41 | + #[\Override ] |
|
42 | 42 | final public function cliConfigure(InputInterface $input, OutputInterface $output): int { |
43 | 43 | $namespaces = $this->providerFactory->getFqcnList(); |
44 | - $schemas = []; |
|
44 | + $schemas = [ ]; |
|
45 | 45 | foreach ($namespaces as $ns) { |
46 | - $schemas[] = $ns::SCHEMA; |
|
46 | + $schemas[ ] = $ns::SCHEMA; |
|
47 | 47 | } |
48 | 48 | $names = array_column($schemas, 'name'); |
49 | 49 | |
@@ -51,32 +51,32 @@ discard block |
||
51 | 51 | $choiceQuestion = new ChoiceQuestion('Please choose a SMS provider:', $names); |
52 | 52 | $name = $helper->ask($input, $output, $choiceQuestion); |
53 | 53 | $selectedIndex = array_search($name, $names); |
54 | - $schema = $schemas[$selectedIndex]; |
|
54 | + $schema = $schemas[ $selectedIndex ]; |
|
55 | 55 | |
56 | - $provider = $this->getProvider($namespaces[$selectedIndex]::getProviderId()); |
|
56 | + $provider = $this->getProvider($namespaces[ $selectedIndex ]::getProviderId()); |
|
57 | 57 | |
58 | - foreach ($schema['fields'] as $field) { |
|
59 | - $id = $field['field']; |
|
60 | - $prompt = $field['prompt'] . ' '; |
|
61 | - $defaultVal = $field['default'] ?? null; |
|
62 | - $optional = (bool)($field['optional'] ?? false); |
|
58 | + foreach ($schema[ 'fields' ] as $field) { |
|
59 | + $id = $field[ 'field' ]; |
|
60 | + $prompt = $field[ 'prompt' ].' '; |
|
61 | + $defaultVal = $field[ 'default' ] ?? null; |
|
62 | + $optional = (bool)($field[ 'optional' ] ?? false); |
|
63 | 63 | |
64 | 64 | $answer = (string)$helper->ask($input, $output, new Question($prompt, $defaultVal)); |
65 | 65 | |
66 | 66 | if ($optional && $answer === '') { |
67 | - $method = 'delete' . $this->toCamel($id); |
|
67 | + $method = 'delete'.$this->toCamel($id); |
|
68 | 68 | $provider->{$method}(); |
69 | 69 | continue; |
70 | 70 | } |
71 | 71 | |
72 | - $method = 'set' . $this->toCamel($id); |
|
72 | + $method = 'set'.$this->toCamel($id); |
|
73 | 73 | $provider->{$method}($answer); |
74 | 74 | } |
75 | 75 | return 0; |
76 | 76 | } |
77 | 77 | |
78 | - #[\Override] |
|
79 | - public function isComplete(array $schema = []): bool { |
|
78 | + #[\Override ] |
|
79 | + public function isComplete(array $schema = [ ]): bool { |
|
80 | 80 | if (empty($schema)) { |
81 | 81 | try { |
82 | 82 | $provider = $this->getProvider(); |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | return parent::isComplete($schema); |
89 | 89 | } |
90 | 90 | |
91 | - #[\Override] |
|
92 | - public function remove(array $schema = []): void { |
|
91 | + #[\Override ] |
|
92 | + public function remove(array $schema = [ ]): void { |
|
93 | 93 | if (empty($schema)) { |
94 | 94 | $schema = static::SCHEMA; |
95 | 95 | } |
@@ -25,10 +25,10 @@ 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( |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $this->addArgument( |
40 | 40 | 'gateway', |
41 | 41 | InputArgument::REQUIRED, |
42 | - 'The name of the gateway: ' . implode(', ', $ids) |
|
42 | + 'The name of the gateway: '.implode(', ', $ids) |
|
43 | 43 | ); |
44 | 44 | $this->addArgument( |
45 | 45 | 'identifier', |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | ); |
49 | 49 | } |
50 | 50 | |
51 | - #[\Override] |
|
51 | + #[\Override ] |
|
52 | 52 | protected function execute(InputInterface $input, OutputInterface $output) { |
53 | 53 | $uid = $input->getArgument('uid'); |
54 | 54 | $user = $this->userManager->get($uid); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | return 1; |
67 | 67 | } |
68 | 68 | |
69 | - $gateway->send($user, $identifier, 'Test', ['code' => '123456']); |
|
69 | + $gateway->send($user, $identifier, 'Test', [ 'code' => '123456' ]); |
|
70 | 70 | return 0; |
71 | 71 | } |
72 | 72 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | 'name' => 'Signal', |
32 | 32 | 'instructions' => 'The gateway can send authentication to your Signal mobile and deskop app.', |
33 | 33 | 'fields' => [ |
34 | - ['field' => 'url', 'prompt' => 'Please enter the URL of the Signal gateway (leave blank to use default):', 'default' => 'http://localhost:5000'], |
|
34 | + [ 'field' => 'url', 'prompt' => 'Please enter the URL of the Signal gateway (leave blank to use default):', 'default' => 'http://localhost:5000' ], |
|
35 | 35 | ], |
36 | 36 | ]; |
37 | 37 | |
@@ -43,29 +43,29 @@ discard block |
||
43 | 43 | parent::__construct($appConfig); |
44 | 44 | } |
45 | 45 | |
46 | - #[\Override] |
|
47 | - public function send(IUser $user, string $identifier, string $message, array $extra = []): void { |
|
46 | + #[\Override ] |
|
47 | + public function send(IUser $user, string $identifier, string $message, array $extra = [ ]): void { |
|
48 | 48 | $client = $this->clientService->newClient(); |
49 | 49 | // determine type of gateway |
50 | - $response = $client->get($this->getUrl() . '/v1/about'); |
|
50 | + $response = $client->get($this->getUrl().'/v1/about'); |
|
51 | 51 | if ($response->getStatusCode() === 200) { |
52 | 52 | // New style gateway https://gitlab.com/morph027/signal-cli-dbus-rest-api |
53 | 53 | $response = $client->post( |
54 | - $this->getUrl() . '/v1/send/' . $identifier, |
|
54 | + $this->getUrl().'/v1/send/'.$identifier, |
|
55 | 55 | [ |
56 | 56 | 'json' => [ 'message' => $message ], |
57 | 57 | ] |
58 | 58 | ); |
59 | 59 | $body = (string)$response->getBody(); |
60 | 60 | $json = json_decode($body, true); |
61 | - if ($response->getStatusCode() !== 201 || is_null($json) || !is_array($json) || !isset($json['timestamp'])) { |
|
61 | + if ($response->getStatusCode() !== 201 || is_null($json) || !is_array($json) || !isset($json[ 'timestamp' ])) { |
|
62 | 62 | $status = $response->getStatusCode(); |
63 | 63 | throw new MessageTransmissionException("error reported by Signal gateway, status=$status, body=$body}"); |
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | // Try old deprecated gateway https://gitlab.com/morph027/signal-web-gateway |
67 | 67 | $response = $client->post( |
68 | - $this->getUrl() . '/v1/send/' . $identifier, |
|
68 | + $this->getUrl().'/v1/send/'.$identifier, |
|
69 | 69 | [ |
70 | 70 | 'body' => [ |
71 | 71 | 'to' => $identifier, |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | $body = (string)$response->getBody(); |
78 | 78 | $json = json_decode($body, true); |
79 | 79 | |
80 | - if ($response->getStatusCode() !== 200 || is_null($json) || !is_array($json) || !isset($json['success']) || $json['success'] !== true) { |
|
80 | + if ($response->getStatusCode() !== 200 || is_null($json) || !is_array($json) || !isset($json[ 'success' ]) || $json[ 'success' ] !== true) { |
|
81 | 81 | $status = $response->getStatusCode(); |
82 | 82 | throw new MessageTransmissionException("error reported by Signal gateway, status=$status, body=$body}"); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - #[\Override] |
|
87 | + #[\Override ] |
|
88 | 88 | public function cliConfigure(InputInterface $input, OutputInterface $output): int { |
89 | 89 | $helper = new QuestionHelper(); |
90 | - $urlQuestion = new Question(self::SCHEMA['fields'][0]['prompt'], self::SCHEMA['fields'][0]['default']); |
|
90 | + $urlQuestion = new Question(self::SCHEMA[ 'fields' ][ 0 ][ 'prompt' ], self::SCHEMA[ 'fields' ][ 0 ][ 'default' ]); |
|
91 | 91 | $url = $helper->ask($input, $output, $urlQuestion); |
92 | 92 | $output->writeln("Using $url."); |
93 | 93 |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | public const SCHEMA = [ |
35 | 35 | 'name' => 'OVH', |
36 | 36 | 'fields' => [ |
37 | - ['field' => 'endpoint', 'prompt' => 'Please enter the endpoint (ovh-eu, ovh-us, ovh-ca, soyoustart-eu, soyoustart-ca, kimsufi-eu, kimsufi-ca, runabove-ca):'], |
|
38 | - ['field' => 'application_key', 'prompt' => 'Please enter your application key:'], |
|
39 | - ['field' => 'application_secret','prompt' => 'Please enter your application secret:'], |
|
40 | - ['field' => 'consumer_key', 'prompt' => 'Please enter your consumer key:'], |
|
41 | - ['field' => 'account', 'prompt' => 'Please enter your account (sms-*****):'], |
|
42 | - ['field' => 'sender', 'prompt' => 'Please enter your sender:'], |
|
37 | + [ 'field' => 'endpoint', 'prompt' => 'Please enter the endpoint (ovh-eu, ovh-us, ovh-ca, soyoustart-eu, soyoustart-ca, kimsufi-eu, kimsufi-ca, runabove-ca):' ], |
|
38 | + [ 'field' => 'application_key', 'prompt' => 'Please enter your application key:' ], |
|
39 | + [ 'field' => 'application_secret', 'prompt' => 'Please enter your application secret:' ], |
|
40 | + [ 'field' => 'consumer_key', 'prompt' => 'Please enter your consumer key:' ], |
|
41 | + [ 'field' => 'account', 'prompt' => 'Please enter your account (sms-*****):' ], |
|
42 | + [ 'field' => 'sender', 'prompt' => 'Please enter your sender:' ], |
|
43 | 43 | ], |
44 | 44 | ]; |
45 | 45 | private IClient $client; |
@@ -76,24 +76,24 @@ discard block |
||
76 | 76 | $this->client = $clientService->newClient(); |
77 | 77 | } |
78 | 78 | |
79 | - #[\Override] |
|
79 | + #[\Override ] |
|
80 | 80 | public function send(string $identifier, string $message) { |
81 | 81 | $endpoint = $this->getEndpoint(); |
82 | 82 | $sender = $this->getSender(); |
83 | 83 | $smsAccount = $this->getAccount(); |
84 | 84 | |
85 | - $this->attrs['AK'] = $this->getApplicationKey(); |
|
86 | - $this->attrs['AS'] = $this->getApplicationSecret(); |
|
87 | - $this->attrs['CK'] = $this->getConsumerKey(); |
|
88 | - if (!isset($this->endpoints[$endpoint])) { |
|
85 | + $this->attrs[ 'AK' ] = $this->getApplicationKey(); |
|
86 | + $this->attrs[ 'AS' ] = $this->getApplicationSecret(); |
|
87 | + $this->attrs[ 'CK' ] = $this->getConsumerKey(); |
|
88 | + if (!isset($this->endpoints[ $endpoint ])) { |
|
89 | 89 | throw new InvalidProviderException("Endpoint $endpoint not found"); |
90 | 90 | } |
91 | - $this->attrs['endpoint'] = $this->endpoints[$endpoint]; |
|
91 | + $this->attrs[ 'endpoint' ] = $this->endpoints[ $endpoint ]; |
|
92 | 92 | |
93 | 93 | $this->getTimeDelta(); |
94 | 94 | |
95 | - $header = $this->getHeader('GET', $this->attrs['endpoint'] . '/sms'); |
|
96 | - $response = $this->client->get($this->attrs['endpoint'] . '/sms', [ |
|
95 | + $header = $this->getHeader('GET', $this->attrs[ 'endpoint' ].'/sms'); |
|
96 | + $response = $this->client->get($this->attrs[ 'endpoint' ].'/sms', [ |
|
97 | 97 | 'headers' => $header, |
98 | 98 | ]); |
99 | 99 | $body = (string)$response->getBody(); |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | ]; |
122 | 122 | $body = json_encode($content); |
123 | 123 | |
124 | - $header = $this->getHeader('POST', $this->attrs['endpoint'] . "/sms/$smsAccount/jobs", $body); |
|
125 | - $response = $this->client->post($this->attrs['endpoint'] . "/sms/$smsAccount/jobs", [ |
|
124 | + $header = $this->getHeader('POST', $this->attrs[ 'endpoint' ]."/sms/$smsAccount/jobs", $body); |
|
125 | + $response = $this->client->post($this->attrs[ 'endpoint' ]."/sms/$smsAccount/jobs", [ |
|
126 | 126 | 'headers' => $header, |
127 | 127 | 'json' => $content, |
128 | 128 | ]); |
129 | 129 | $body = (string)$response->getBody(); |
130 | 130 | $resultPostJob = json_decode($body, true); |
131 | 131 | |
132 | - if (count($resultPostJob['validReceivers']) === 0) { |
|
132 | + if (count($resultPostJob[ 'validReceivers' ]) === 0) { |
|
133 | 133 | throw new MessageTransmissionException("Bad receiver $identifier"); |
134 | 134 | } |
135 | 135 | } |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | * @throws InvalidProviderException |
141 | 141 | */ |
142 | 142 | private function getTimeDelta(): void { |
143 | - if (!isset($this->attrs['timedelta'])) { |
|
144 | - if (!isset($this->attrs['endpoint'])) { |
|
143 | + if (!isset($this->attrs[ 'timedelta' ])) { |
|
144 | + if (!isset($this->attrs[ 'endpoint' ])) { |
|
145 | 145 | throw new InvalidProviderException('Need to set the endpoint'); |
146 | 146 | } |
147 | 147 | try { |
148 | - $response = $this->client->get($this->attrs['endpoint'] . '/auth/time'); |
|
148 | + $response = $this->client->get($this->attrs[ 'endpoint' ].'/auth/time'); |
|
149 | 149 | $serverTimestamp = (int)$response->getBody(); |
150 | - $this->attrs['timedelta'] = $serverTimestamp - time(); |
|
150 | + $this->attrs[ 'timedelta' ] = $serverTimestamp - time(); |
|
151 | 151 | } catch (Exception $ex) { |
152 | - throw new InvalidProviderException('Unable to calculate time delta:' . $ex->getMessage()); |
|
152 | + throw new InvalidProviderException('Unable to calculate time delta:'.$ex->getMessage()); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | * @return array $header Contains the data for the request need by OVH |
163 | 163 | */ |
164 | 164 | private function getHeader($method, $query, $body = '') { |
165 | - $timestamp = time() + $this->attrs['timedelta']; |
|
166 | - $prehash = $this->attrs['AS'] . '+' . $this->attrs['CK'] . '+' . $method . '+' . $query . '+' . $body . '+' . $timestamp; |
|
165 | + $timestamp = time() + $this->attrs[ 'timedelta' ]; |
|
166 | + $prehash = $this->attrs[ 'AS' ].'+'.$this->attrs[ 'CK' ].'+'.$method.'+'.$query.'+'.$body.'+'.$timestamp; |
|
167 | 167 | $header = [ |
168 | 168 | 'Content-Type' => 'application/json; charset=utf-8', |
169 | - 'X-Ovh-Application' => $this->attrs['AK'], |
|
169 | + 'X-Ovh-Application' => $this->attrs[ 'AK' ], |
|
170 | 170 | 'X-Ovh-Timestamp' => $timestamp, |
171 | - 'X-Ovh-Signature' => '$1$' . sha1($prehash), |
|
172 | - 'X-Ovh-Consumer' => $this->attrs['CK'], |
|
171 | + 'X-Ovh-Signature' => '$1$'.sha1($prehash), |
|
172 | + 'X-Ovh-Consumer' => $this->attrs[ 'CK' ], |
|
173 | 173 | ]; |
174 | 174 | return $header; |
175 | 175 | } |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | public const SCHEMA = [ |
28 | 28 | 'name' => 'SerwerSMS', |
29 | 29 | 'fields' => [ |
30 | - ['field' => 'login', 'prompt' => 'Please enter your SerwerSMS.pl API login:'], |
|
31 | - ['field' => 'password', 'prompt' => 'Please enter your SerwerSMS.pl API password:'], |
|
32 | - ['field' => 'sender', 'prompt' => 'Please enter your SerwerSMS.pl sender name:'], |
|
30 | + [ 'field' => 'login', 'prompt' => 'Please enter your SerwerSMS.pl API login:' ], |
|
31 | + [ 'field' => 'password', 'prompt' => 'Please enter your SerwerSMS.pl API password:' ], |
|
32 | + [ 'field' => 'sender', 'prompt' => 'Please enter your SerwerSMS.pl sender name:' ], |
|
33 | 33 | ], |
34 | 34 | ]; |
35 | 35 | private IClient $client; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $this->client = $clientService->newClient(); |
41 | 41 | } |
42 | 42 | |
43 | - #[\Override] |
|
43 | + #[\Override ] |
|
44 | 44 | public function send(string $identifier, string $message) { |
45 | 45 | $login = $this->getLogin(); |
46 | 46 | $password = $this->getPassword(); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | $responseData = json_decode((string)$response->getBody(), true); |
63 | 63 | |
64 | - if ($responseData['success'] !== true) { |
|
64 | + if ($responseData[ 'success' ] !== true) { |
|
65 | 65 | throw new MessageTransmissionException(); |
66 | 66 | } |
67 | 67 | } catch (Exception $ex) { |