@@ -29,20 +29,20 @@ discard block |
||
| 29 | 29 | parent::__construct($appConfig); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - #[\Override] |
|
| 33 | - public function send(string $identifier, string $message, array $extra = []): void { |
|
| 32 | + #[\Override ] |
|
| 33 | + public function send(string $identifier, string $message, array $extra = [ ]): void { |
|
| 34 | 34 | $this->getProvider()->send($identifier, $message); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - #[\Override] |
|
| 37 | + #[\Override ] |
|
| 38 | 38 | final public function cliConfigure(InputInterface $input, OutputInterface $output): int { |
| 39 | 39 | $namespaces = $this->telegramProviderFactory->getFqcnList(); |
| 40 | - $names = []; |
|
| 41 | - $providers = []; |
|
| 40 | + $names = [ ]; |
|
| 41 | + $providers = [ ]; |
|
| 42 | 42 | foreach ($namespaces as $ns) { |
| 43 | 43 | $provider = $this->telegramProviderFactory->get($ns); |
| 44 | - $providers[] = $provider; |
|
| 45 | - $names[] = $provider->getSettings()->name; |
|
| 44 | + $providers[ ] = $provider; |
|
| 45 | + $names[ ] = $provider->getSettings()->name; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $helper = new QuestionHelper(); |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | $name = $helper->ask($input, $output, $choiceQuestion); |
| 51 | 51 | $selectedIndex = array_search($name, $names); |
| 52 | 52 | |
| 53 | - $providers[$selectedIndex]->cliConfigure($input, $output); |
|
| 53 | + $providers[ $selectedIndex ]->cliConfigure($input, $output); |
|
| 54 | 54 | return 0; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - #[\Override] |
|
| 57 | + #[\Override ] |
|
| 58 | 58 | public function createSettings(): Settings { |
| 59 | 59 | try { |
| 60 | 60 | $settings = $this->getProvider()->getSettings(); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | return $settings; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - #[\Override] |
|
| 69 | + #[\Override ] |
|
| 70 | 70 | public function isComplete(?Settings $settings = null): bool { |
| 71 | 71 | if ($settings === null) { |
| 72 | 72 | try { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | return parent::isComplete($settings); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - #[\Override] |
|
| 82 | + #[\Override ] |
|
| 83 | 83 | public function remove(?Settings $settings = null): void { |
| 84 | 84 | foreach ($this->telegramProviderFactory->getFqcnList() as $fqcn) { |
| 85 | 85 | $provider = $this->telegramProviderFactory->get($fqcn); |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | ); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - #[\Override] |
|
| 58 | - public function send(string $identifier, string $message, array $extra = []): void { |
|
| 57 | + #[\Override ] |
|
| 58 | + public function send(string $identifier, string $message, array $extra = [ ]): void { |
|
| 59 | 59 | if (empty($message)) { |
| 60 | - $message = $this->l10n->t('`%s` is your Nextcloud verification code.', [$extra['code']]); |
|
| 60 | + $message = $this->l10n->t('`%s` is your Nextcloud verification code.', [ $extra[ 'code' ] ]); |
|
| 61 | 61 | } |
| 62 | 62 | $this->logger->debug("sending telegram message to $identifier, message: $message"); |
| 63 | 63 | $token = $this->getToken(); |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | $this->logger->debug("telegram message to chat $identifier sent"); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - #[\Override] |
|
| 79 | + #[\Override ] |
|
| 80 | 80 | public function cliConfigure(InputInterface $input, OutputInterface $output): int { |
| 81 | 81 | $helper = new QuestionHelper(); |
| 82 | 82 | $settings = $this->getSettings(); |
| 83 | - $tokenQuestion = new Question($settings->fields[0]->prompt . ' '); |
|
| 83 | + $tokenQuestion = new Question($settings->fields[ 0 ]->prompt.' '); |
|
| 84 | 84 | $token = $helper->ask($input, $output, $tokenQuestion); |
| 85 | 85 | $this->setToken($token); |
| 86 | 86 | $output->writeln("Using $token."); |
@@ -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; |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | return $this->settings; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - #[\Override] |
|
| 60 | + #[\Override ] |
|
| 61 | 61 | abstract public function cliConfigure(InputInterface $input, OutputInterface $output): int; |
| 62 | 62 | |
| 63 | - #[\Override] |
|
| 63 | + #[\Override ] |
|
| 64 | 64 | public function remove(?Settings $settings = null): void { |
| 65 | 65 | if (!is_object($settings)) { |
| 66 | 66 | $settings = $this->getSettings(); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $this->settings = $settings; |
| 69 | 69 | } |
| 70 | 70 | foreach ($settings->fields as $field) { |
| 71 | - $method = 'delete' . $this->toCamel($field->field); |
|
| 71 | + $method = 'delete'.$this->toCamel($field->field); |
|
| 72 | 72 | $this->{$method}(); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | return str_replace(' ', '', ucwords(str_replace('_', ' ', $field))); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - #[\Override] |
|
| 80 | + #[\Override ] |
|
| 81 | 81 | public function getProviderId(): string { |
| 82 | 82 | $id = self::deriveIdFromFqcn(static::class); |
| 83 | 83 | if ($id === null) { |
| 84 | - throw new \LogicException('Cannot derive gateway id from FQCN: ' . static::class); |
|
| 84 | + throw new \LogicException('Cannot derive gateway id from FQCN: '.static::class); |
|
| 85 | 85 | } |
| 86 | 86 | return $id; |
| 87 | 87 | } |
@@ -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 $settings->id . '_' . $fieldName; |
|
| 55 | + return $settings->id.'_'.$fieldName; |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | - throw new ConfigurationException('Invalid configuration field: ' . $fieldName . ', check SCHEMA at ' . static::class); |
|
| 58 | + throw new ConfigurationException('Invalid configuration field: '.$fieldName.', check SCHEMA at '.static::class); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |