@@ -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) { |
@@ -22,15 +22,15 @@ discard block |
||
| 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,19 +38,19 @@ discard block |
||
| 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 | if ($this->settings->id ?? null) { |
| 49 | 49 | return $this->settings->id; |
| 50 | 50 | } |
| 51 | 51 | $id = self::getIdFromProviderFqcn(static::class); |
| 52 | 52 | if ($id === null) { |
| 53 | - throw new \LogicException('Cannot derive gateway id from FQCN: ' . static::class); |
|
| 53 | + throw new \LogicException('Cannot derive gateway id from FQCN: '.static::class); |
|
| 54 | 54 | } |
| 55 | 55 | return $id; |
| 56 | 56 | } |
@@ -13,9 +13,9 @@ discard block |
||
| 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 | |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function get(string $name): object { |
| 32 | 32 | $needle = strtolower($name); |
| 33 | - if (isset($this->instances[$needle])) { |
|
| 34 | - return $this->instances[$needle]; |
|
| 33 | + if (isset($this->instances[ $needle ])) { |
|
| 34 | + return $this->instances[ $needle ]; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | foreach ($this->getFqcnList() as $fqcn) { |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | continue; |
| 41 | 41 | } |
| 42 | 42 | $instance = \OCP\Server::get($fqcn); |
| 43 | - $this->instances[$type] = $instance; |
|
| 43 | + $this->instances[ $type ] = $instance; |
|
| 44 | 44 | return $instance; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | return $this->fqcn; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $loader = require __DIR__ . '/../../vendor/autoload.php'; |
|
| 56 | + $loader = require __DIR__.'/../../vendor/autoload.php'; |
|
| 57 | 57 | foreach ($loader->getClassMap() as $fqcn => $_) { |
| 58 | 58 | $type = $this->typeFrom($fqcn); |
| 59 | 59 | if ($type === null) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | if (!is_subclass_of($fqcn, $this->getBaseClass(), true)) { |
| 63 | 63 | continue; |
| 64 | 64 | } |
| 65 | - $this->fqcn[] = $fqcn; |
|
| 65 | + $this->fqcn[ ] = $fqcn; |
|
| 66 | 66 | } |
| 67 | 67 | return $this->fqcn; |
| 68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | return null; |
| 78 | 78 | } |
| 79 | 79 | $type = substr($fqcn, strlen($prefix)); |
| 80 | - $type = substr($type, 0, -strlen('\\' . $suffix)); |
|
| 80 | + $type = substr($type, 0, -strlen('\\'.$suffix)); |
|
| 81 | 81 | if (strpos($type, '\\') !== false || $type === '') { |
| 82 | 82 | return null; |
| 83 | 83 | } |
@@ -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 | |
@@ -20,28 +20,28 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function __call(string $name, array $args) { |
| 22 | 22 | if (!preg_match('/^(?<operation>get|set|delete)(?<field>[A-Z][A-Za-z0-9_]*)$/', $name, $matches)) { |
| 23 | - throw new ConfigurationException('Invalid method ' . $name); |
|
| 23 | + throw new ConfigurationException('Invalid method '.$name); |
|
| 24 | 24 | } |
| 25 | - $field = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $matches['field'])); |
|
| 25 | + $field = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $matches[ 'field' ])); |
|
| 26 | 26 | $key = $this->keyFromField($field); |
| 27 | 27 | |
| 28 | - switch ($matches['operation']) { |
|
| 28 | + switch ($matches[ 'operation' ]) { |
|
| 29 | 29 | case 'get': |
| 30 | 30 | $val = (string)$this->getAppConfig()->getValueString(Application::APP_ID, $key, ''); |
| 31 | 31 | if ($val === '') { |
| 32 | - throw new ConfigurationException('No value set for ' . $field); |
|
| 32 | + throw new ConfigurationException('No value set for '.$field); |
|
| 33 | 33 | } |
| 34 | 34 | return $val; |
| 35 | 35 | |
| 36 | 36 | case 'set': |
| 37 | - $this->getAppConfig()->setValueString(Application::APP_ID, $key, (string)($args[0] ?? '')); |
|
| 37 | + $this->getAppConfig()->setValueString(Application::APP_ID, $key, (string)($args[ 0 ] ?? '')); |
|
| 38 | 38 | return $this; |
| 39 | 39 | |
| 40 | 40 | case 'delete': |
| 41 | 41 | $this->getAppConfig()->deleteKey(Application::APP_ID, $key); |
| 42 | 42 | return $this; |
| 43 | 43 | } |
| 44 | - throw new ConfigurationException('Invalid operation ' . $matches['operation']); |
|
| 44 | + throw new ConfigurationException('Invalid operation '.$matches[ 'operation' ]); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | $fields = $settings->fields; |
| 53 | 53 | foreach ($fields as $field) { |
| 54 | 54 | if ($field->field === $fieldName) { |
| 55 | - return $this->getProviderId() . '_' . $fieldName; |
|
| 55 | + return $this->getProviderId().'_'.$fieldName; |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | - throw new ConfigurationException('Invalid configuration field: ' . $field->field . ', check SCHEMA at ' . static::class); |
|
| 58 | + throw new ConfigurationException('Invalid configuration field: '.$field->field.', check SCHEMA at '.static::class); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | abstract class AGateway implements IGateway { |
| 20 | 20 | use TConfigurable; |
| 21 | - public const SCHEMA = []; |
|
| 21 | + public const SCHEMA = [ ]; |
|
| 22 | 22 | protected ?Settings $settings = null; |
| 23 | 23 | |
| 24 | 24 | public function __construct( |
@@ -29,25 +29,25 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @throws MessageTransmissionException |
| 31 | 31 | */ |
| 32 | - #[\Override] |
|
| 33 | - abstract public function send(string $identifier, string $message, array $extra = []): void; |
|
| 32 | + #[\Override ] |
|
| 33 | + abstract public function send(string $identifier, string $message, array $extra = [ ]): void; |
|
| 34 | 34 | |
| 35 | - #[\Override] |
|
| 35 | + #[\Override ] |
|
| 36 | 36 | public function isComplete(?Settings $settings = null): bool { |
| 37 | 37 | if (!is_object($settings)) { |
| 38 | 38 | $settings = $this->getSettings(); |
| 39 | 39 | } |
| 40 | 40 | $savedKeys = $this->appConfig->getKeys(Application::APP_ID); |
| 41 | 41 | $providerId = $settings->id ?? $this->getProviderId(); |
| 42 | - $fields = []; |
|
| 42 | + $fields = [ ]; |
|
| 43 | 43 | foreach ($settings->fields as $field) { |
| 44 | - $fields[] = $providerId . '_' . $field->field; |
|
| 44 | + $fields[ ] = $providerId.'_'.$field->field; |
|
| 45 | 45 | } |
| 46 | 46 | $intersect = array_intersect($fields, $savedKeys); |
| 47 | 47 | return count($intersect) === count($fields); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - #[\Override] |
|
| 50 | + #[\Override ] |
|
| 51 | 51 | public function getSettings(): Settings { |
| 52 | 52 | if ($this->settings !== null) { |
| 53 | 53 | return $this->settings; |
@@ -55,16 +55,16 @@ discard block |
||
| 55 | 55 | return $this->settings = $this->createSettings(); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - #[\Override] |
|
| 58 | + #[\Override ] |
|
| 59 | 59 | abstract public function cliConfigure(InputInterface $input, OutputInterface $output): int; |
| 60 | 60 | |
| 61 | - #[\Override] |
|
| 61 | + #[\Override ] |
|
| 62 | 62 | public function remove(?Settings $settings = null): void { |
| 63 | 63 | if (!is_object($settings)) { |
| 64 | 64 | $settings = $this->getSettings(); |
| 65 | 65 | } |
| 66 | 66 | foreach ($settings->fields as $field) { |
| 67 | - $method = 'delete' . $this->toCamel($field->field); |
|
| 67 | + $method = 'delete'.$this->toCamel($field->field); |
|
| 68 | 68 | $this->{$method}(); |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | return str_replace(' ', '', ucwords(str_replace('_', ' ', $field))); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - #[\Override] |
|
| 76 | + #[\Override ] |
|
| 77 | 77 | public static function getProviderId(): string { |
| 78 | 78 | $id = self::deriveIdFromFqcn(static::class); |
| 79 | 79 | if ($id === null) { |
| 80 | - throw new \LogicException('Cannot derive gateway id from FQCN: ' . static::class); |
|
| 80 | + throw new \LogicException('Cannot derive gateway id from FQCN: '.static::class); |
|
| 81 | 81 | } |
| 82 | 82 | return $id; |
| 83 | 83 | } |
@@ -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,7 +22,7 @@ discard block |
||
| 22 | 22 | parent::__construct('twofactorauth:gateway:status'); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - #[\Override] |
|
| 25 | + #[\Override ] |
|
| 26 | 26 | protected function execute(InputInterface $input, OutputInterface $output) { |
| 27 | 27 | $fqcn = $this->gatewayFactory->getFqcnList(); |
| 28 | 28 | foreach ($fqcn as $fqcn) { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $gateway = $this->gatewayFactory->get($fqcn); |
| 31 | 31 | $isConfigured = $gateway->isComplete(); |
| 32 | 32 | $settings = $gateway->getSettings(); |
| 33 | - $output->writeln($settings->name . ': ' . ($isConfigured ? 'configured' : 'not configured')); |
|
| 33 | + $output->writeln($settings->name.': '.($isConfigured ? 'configured' : 'not configured')); |
|
| 34 | 34 | } |
| 35 | 35 | return 0; |
| 36 | 36 | } |
@@ -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, |