diff options
author | Niklas Seyfarth <niklas@seyfarth.de> | 2021-06-03 14:33:48 +0300 |
---|---|---|
committer | Niklas Seyfarth <niklas@seyfarth.de> | 2021-06-06 16:30:31 +0300 |
commit | 5d67d632c73903b8cd97f5330d5175fc6368adae (patch) | |
tree | fe7a38d5cbc55e04807b45ea6886c5fcee448119 /lib | |
parent | 459bcd83a7be79fe7568cd312cdddafcfae49824 (diff) |
Fix issues found by php-cs.
Signed-off-by: Niklas Seyfarth <niklas@seyfarth.de>
Diffstat (limited to 'lib')
19 files changed, 73 insertions, 73 deletions
diff --git a/lib/Command/Remove.php b/lib/Command/Remove.php index c4aa4b3..2e2123b 100644 --- a/lib/Command/Remove.php +++ b/lib/Command/Remove.php @@ -65,7 +65,7 @@ class Remove extends Command { $gateway = null; switch ($gatewayName) { case 'signal': - $gateway = $this->signalGateway; + $gateway = $this->signalGateway; break; case 'sms': $gateway = $this->smsGateway; diff --git a/lib/Service/Gateway/SMS/Provider/ClickSendConfig.php b/lib/Service/Gateway/SMS/Provider/ClickSendConfig.php index 4ec4a9b..14523f8 100644 --- a/lib/Service/Gateway/SMS/Provider/ClickSendConfig.php +++ b/lib/Service/Gateway/SMS/Provider/ClickSendConfig.php @@ -29,6 +29,10 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class ClickSendConfig implements IProviderConfig { + private const expected = [ + 'clicksend_user', + 'clicksend_apikey', + ]; /** @var IConfig */ private $config; @@ -63,10 +67,12 @@ class ClickSendConfig implements IProviderConfig { public function isComplete(): bool { $set = $this->config->getAppKeys(Application::APP_NAME); - $expected = [ - 'clicksend_user', - 'clicksend_apikey', - ]; - return count(array_intersect($set, $expected)) === count($expected); + return count(array_intersect($set, self::expected)) === count(self::expected); + } + + public function remove() { + foreach (self::expected as $key) { + $this->config->deleteAppValue(Application::APP_NAME, $key); + } } } diff --git a/lib/Service/Gateway/SMS/Provider/ClickatellCentralConfig.php b/lib/Service/Gateway/SMS/Provider/ClickatellCentralConfig.php index 6d57238..c1cdd59 100644 --- a/lib/Service/Gateway/SMS/Provider/ClickatellCentralConfig.php +++ b/lib/Service/Gateway/SMS/Provider/ClickatellCentralConfig.php @@ -30,8 +30,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class ClickatellCentralConfig implements IProviderConfig { - - const expected = [ + private const expected = [ 'clickatell_central_api', 'clickatell_central_user', 'clickatell_central_password', @@ -82,7 +81,7 @@ class ClickatellCentralConfig implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/SMS/Provider/ClockworkSMSConfig.php b/lib/Service/Gateway/SMS/Provider/ClockworkSMSConfig.php index 96f3a02..955aa24 100644 --- a/lib/Service/Gateway/SMS/Provider/ClockworkSMSConfig.php +++ b/lib/Service/Gateway/SMS/Provider/ClockworkSMSConfig.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class ClockworkSMSConfig implements IProviderConfig { - - const expected = [ + private const expected = [ 'clockworksms_apitoken' ]; @@ -63,7 +62,7 @@ class ClockworkSMSConfig implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/SMS/Provider/EcallSMSConfig.php b/lib/Service/Gateway/SMS/Provider/EcallSMSConfig.php index ab381be..e11d28b 100644 --- a/lib/Service/Gateway/SMS/Provider/EcallSMSConfig.php +++ b/lib/Service/Gateway/SMS/Provider/EcallSMSConfig.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class EcallSMSConfig implements IProviderConfig { - - const expected = [ + private const expected = [ 'ecallsms_username', 'ecallsms_password', 'ecallsms_senderid', @@ -81,7 +80,7 @@ class EcallSMSConfig implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/SMS/Provider/HuaweiE3531Config.php b/lib/Service/Gateway/SMS/Provider/HuaweiE3531Config.php index 3dc36c6..efafa88 100644 --- a/lib/Service/Gateway/SMS/Provider/HuaweiE3531Config.php +++ b/lib/Service/Gateway/SMS/Provider/HuaweiE3531Config.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class HuaweiE3531Config implements IProviderConfig { - - const expected = [ + private const expected = [ 'huawei_e3531_api', ]; @@ -63,7 +62,7 @@ class HuaweiE3531Config implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/SMS/Provider/IProviderConfig.php b/lib/Service/Gateway/SMS/Provider/IProviderConfig.php index e72394a..7226115 100644 --- a/lib/Service/Gateway/SMS/Provider/IProviderConfig.php +++ b/lib/Service/Gateway/SMS/Provider/IProviderConfig.php @@ -25,4 +25,5 @@ namespace OCA\TwoFactorGateway\Service\Gateway\SMS\Provider; interface IProviderConfig { public function isComplete(): bool; + public function remove(); } diff --git a/lib/Service/Gateway/SMS/Provider/Ovh.php b/lib/Service/Gateway/SMS/Provider/Ovh.php index befeddc..4149f72 100644 --- a/lib/Service/Gateway/SMS/Provider/Ovh.php +++ b/lib/Service/Gateway/SMS/Provider/Ovh.php @@ -44,14 +44,14 @@ class Ovh implements IProvider { * @var array */ private $endpoints = [ - 'ovh-eu' => 'https://api.ovh.com/1.0', - 'ovh-us' => 'https://api.us.ovhcloud.com/1.0', - 'ovh-ca' => 'https://ca.api.ovh.com/1.0', - 'kimsufi-eu' => 'https://eu.api.kimsufi.com/1.0', - 'kimsufi-ca' => 'https://ca.api.kimsufi.com/1.0', + 'ovh-eu' => 'https://api.ovh.com/1.0', + 'ovh-us' => 'https://api.us.ovhcloud.com/1.0', + 'ovh-ca' => 'https://ca.api.ovh.com/1.0', + 'kimsufi-eu' => 'https://eu.api.kimsufi.com/1.0', + 'kimsufi-ca' => 'https://ca.api.kimsufi.com/1.0', 'soyoustart-eu' => 'https://eu.api.soyoustart.com/1.0', 'soyoustart-ca' => 'https://ca.api.soyoustart.com/1.0', - 'runabove-ca' => 'https://api.runabove.com/1.0', + 'runabove-ca' => 'https://api.runabove.com/1.0', ]; /** @@ -112,14 +112,14 @@ class Ovh implements IProvider { throw new InvalidSmsProviderException("SMS account $smsAccount not found"); } $content = [ - "charset"=> "UTF-8", - "message"=> $message, - "noStopClause"=> true, - "priority"=> "high", - "receivers"=> [ $identifier ], - "senderForResponse"=> false, - "sender"=> $sender, - "validityPeriod"=> 3600 + "charset" => "UTF-8", + "message" => $message, + "noStopClause" => true, + "priority" => "high", + "receivers" => [ $identifier ], + "senderForResponse" => false, + "sender" => $sender, + "validityPeriod" => 3600 ]; $body = json_encode($content); @@ -152,8 +152,8 @@ class Ovh implements IProvider { throw new InvalidSmsProviderException('Need to set the endpoint'); } try { - $response = $this->client->get($this->attrs['endpoint'].'/auth/time'); - $serverTimestamp = (int)$response->getBody(); + $response = $this->client->get($this->attrs['endpoint'].'/auth/time'); + $serverTimestamp = (int)$response->getBody(); $this->attrs['timedelta'] = $serverTimestamp - time(); } catch (Exception $ex) { throw new InvalidSmsProviderException('Unable to calculate time delta:'.$ex->getMessage()); @@ -168,15 +168,15 @@ class Ovh implements IProvider { * @param string $body JSON encoded body content for the POST request * @return array $header Contains the data for the request need by OVH */ - private function getHeader($method,$query,$body='') { + private function getHeader($method,$query,$body = '') { $timestamp = time() + $this->attrs['timedelta']; $prehash = $this->attrs['AS'].'+'.$this->attrs['CK'].'+'.$method.'+'.$query.'+'.$body.'+'.$timestamp; $header = [ - 'Content-Type' => 'application/json; charset=utf-8', + 'Content-Type' => 'application/json; charset=utf-8', 'X-Ovh-Application' => $this->attrs['AK'], - 'X-Ovh-Timestamp' => $timestamp, - 'X-Ovh-Signature' => '$1$'.sha1($prehash), - 'X-Ovh-Consumer' => $this->attrs['CK'], + 'X-Ovh-Timestamp' => $timestamp, + 'X-Ovh-Signature' => '$1$'.sha1($prehash), + 'X-Ovh-Consumer' => $this->attrs['CK'], ]; return $header; } diff --git a/lib/Service/Gateway/SMS/Provider/OvhConfig.php b/lib/Service/Gateway/SMS/Provider/OvhConfig.php index 5b5121e..0e4793d 100644 --- a/lib/Service/Gateway/SMS/Provider/OvhConfig.php +++ b/lib/Service/Gateway/SMS/Provider/OvhConfig.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class OvhConfig implements IProviderConfig { - - const expected = [ + private const expected = [ 'ovh_application_key', 'ovh_application_secret', 'ovh_consumer_key', @@ -108,7 +107,7 @@ class OvhConfig implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/SMS/Provider/PlaySMSConfig.php b/lib/Service/Gateway/SMS/Provider/PlaySMSConfig.php index 716022f..5f0f2ec 100644 --- a/lib/Service/Gateway/SMS/Provider/PlaySMSConfig.php +++ b/lib/Service/Gateway/SMS/Provider/PlaySMSConfig.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class PlaySMSConfig implements IProviderConfig { - - const expected = [ + private const expected = [ 'playsms_url', 'playsms_user', 'playsms_password', @@ -81,7 +80,7 @@ class PlaySMSConfig implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/SMS/Provider/PuzzelSMS.php b/lib/Service/Gateway/SMS/Provider/PuzzelSMS.php index ea8c8d8..6d1d0cf 100644 --- a/lib/Service/Gateway/SMS/Provider/PuzzelSMS.php +++ b/lib/Service/Gateway/SMS/Provider/PuzzelSMS.php @@ -61,7 +61,7 @@ class PuzzelSMS implements IProvider { 'password' => $config->getPassword(), "message[0].recipient" => "+".$identifier, "message[0].content" => $message, - 'serviceId'=> $config->getServiceId(), + 'serviceId' => $config->getServiceId(), ], ] ); diff --git a/lib/Service/Gateway/SMS/Provider/PuzzelSMSConfig.php b/lib/Service/Gateway/SMS/Provider/PuzzelSMSConfig.php index 2b3dd9b..09d6b30 100644 --- a/lib/Service/Gateway/SMS/Provider/PuzzelSMSConfig.php +++ b/lib/Service/Gateway/SMS/Provider/PuzzelSMSConfig.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class PuzzelSMSConfig implements IProviderConfig { - - const expected = [ + private const expected = [ 'puzzel_url', 'puzzel_user', 'puzzel_password', @@ -90,7 +89,7 @@ class PuzzelSMSConfig implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/SMS/Provider/Sms77IoConfig.php b/lib/Service/Gateway/SMS/Provider/Sms77IoConfig.php index ca1992f..eebc71c 100644 --- a/lib/Service/Gateway/SMS/Provider/Sms77IoConfig.php +++ b/lib/Service/Gateway/SMS/Provider/Sms77IoConfig.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class Sms77IoConfig implements IProviderConfig { - - const expected = [ + private const expected = [ 'sms77io_api_key', ]; @@ -63,7 +62,7 @@ class Sms77IoConfig implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/SMS/Provider/SpryngSMSConfig.php b/lib/Service/Gateway/SMS/Provider/SpryngSMSConfig.php index 6ffa2a6..4670573 100644 --- a/lib/Service/Gateway/SMS/Provider/SpryngSMSConfig.php +++ b/lib/Service/Gateway/SMS/Provider/SpryngSMSConfig.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class SpryngSMSConfig implements IProviderConfig { - - const expected = [ + private const expected = [ 'spryng_apitoken' ]; @@ -63,7 +62,7 @@ class SpryngSMSConfig implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/SMS/Provider/VoipMsConfig.php b/lib/Service/Gateway/SMS/Provider/VoipMsConfig.php index 4d4bae9..7b3cdca 100644 --- a/lib/Service/Gateway/SMS/Provider/VoipMsConfig.php +++ b/lib/Service/Gateway/SMS/Provider/VoipMsConfig.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class VoipMsConfig implements IProviderConfig { - - const expected = [ + private const expected = [ 'voipms_api_username', 'voipms_api_password', 'voipms_did', @@ -81,7 +80,7 @@ class VoipMsConfig implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/SMS/Provider/VoipbusterConfig.php b/lib/Service/Gateway/SMS/Provider/VoipbusterConfig.php index 49dc867..27d8127 100644 --- a/lib/Service/Gateway/SMS/Provider/VoipbusterConfig.php +++ b/lib/Service/Gateway/SMS/Provider/VoipbusterConfig.php @@ -29,6 +29,11 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class VoipbusterConfig implements IProviderConfig { + private const expected = [ + 'voipbuster_api_username', + 'voipbuster_api_password', + 'voipbuster_did', + ]; /** @var IConfig */ private $config; @@ -71,11 +76,12 @@ class VoipbusterConfig implements IProviderConfig { public function isComplete(): bool { $set = $this->config->getAppKeys(Application::APP_NAME); - $expected = [ - 'voipbuster_api_username', - 'voipbuster_api_password', - 'voipbuster_did', - ]; - return count(array_intersect($set, $expected)) === count($expected); + return count(array_intersect($set, self::expected)) === count(self::expected); + } + + public function remove() { + foreach (self::expected as $key) { + $this->config->deleteAppValue(Application::APP_NAME, $key); + } } } diff --git a/lib/Service/Gateway/SMS/Provider/WebSmsConfig.php b/lib/Service/Gateway/SMS/Provider/WebSmsConfig.php index 5b2486d..facfdea 100644 --- a/lib/Service/Gateway/SMS/Provider/WebSmsConfig.php +++ b/lib/Service/Gateway/SMS/Provider/WebSmsConfig.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Exception\ConfigurationException; use OCP\IConfig; class WebSmsConfig implements IProviderConfig { - - const expected = [ + private const expected = [ 'websms_de_user', 'websms_de_password', ]; @@ -72,7 +71,7 @@ class WebSmsConfig implements IProviderConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/Signal/GatewayConfig.php b/lib/Service/Gateway/Signal/GatewayConfig.php index 52d28a5..d35d958 100644 --- a/lib/Service/Gateway/Signal/GatewayConfig.php +++ b/lib/Service/Gateway/Signal/GatewayConfig.php @@ -29,8 +29,7 @@ use OCA\TwoFactorGateway\Service\Gateway\IGatewayConfig; use OCP\IConfig; class GatewayConfig implements IGatewayConfig { - - const expected = [ + private const expected = [ 'signal_url', ]; @@ -63,7 +62,7 @@ class GatewayConfig implements IGatewayConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } diff --git a/lib/Service/Gateway/Telegram/GatewayConfig.php b/lib/Service/Gateway/Telegram/GatewayConfig.php index 457d194..3aff370 100644 --- a/lib/Service/Gateway/Telegram/GatewayConfig.php +++ b/lib/Service/Gateway/Telegram/GatewayConfig.php @@ -31,8 +31,7 @@ use OCA\TwoFactorGateway\Service\Gateway\IGatewayConfig; use OCP\IConfig; class GatewayConfig implements IGatewayConfig { - - const expected = [ + private const expected = [ 'telegram_bot_token', ]; @@ -65,7 +64,7 @@ class GatewayConfig implements IGatewayConfig { } public function remove() { - foreach(self::expected as $key) { + foreach (self::expected as $key) { $this->config->deleteAppValue(Application::APP_NAME, $key); } } |