@@ -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 | $fqcnList = $this->gatewayFactory->getFqcnList(); |
| 28 | 28 | foreach ($fqcnList 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 | $output->write(print_r($gateway->getConfiguration(), true), true, OutputInterface::VERBOSITY_VERBOSE); |
| 35 | 35 | } |
| 36 | 36 | return 0; |
@@ -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,33 +29,33 @@ 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[] = self::keyFromFieldName($providerId, $field->field); |
|
| 44 | + $fields[ ] = self::keyFromFieldName($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 getConfiguration(?Settings $settings = null): array { |
| 52 | 52 | if (!is_object($settings)) { |
| 53 | 53 | $settings = $this->getSettings(); |
| 54 | 54 | } |
| 55 | 55 | $providerId = $settings->id ?? $this->getProviderId(); |
| 56 | - $config = []; |
|
| 56 | + $config = [ ]; |
|
| 57 | 57 | foreach ($settings->fields as $field) { |
| 58 | - $config[$field->field] = $this->appConfig->getValueString( |
|
| 58 | + $config[ $field->field ] = $this->appConfig->getValueString( |
|
| 59 | 59 | Application::APP_ID, |
| 60 | 60 | self::keyFromFieldName($providerId, $field->field), |
| 61 | 61 | $field->default, |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | return $config; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - #[\Override] |
|
| 67 | + #[\Override ] |
|
| 68 | 68 | public function getSettings(): Settings { |
| 69 | 69 | if ($this->settings !== null) { |
| 70 | 70 | return $this->settings; |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | return $this->settings; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - #[\Override] |
|
| 77 | + #[\Override ] |
|
| 78 | 78 | abstract public function cliConfigure(InputInterface $input, OutputInterface $output): int; |
| 79 | 79 | |
| 80 | - #[\Override] |
|
| 80 | + #[\Override ] |
|
| 81 | 81 | public function remove(?Settings $settings = null): void { |
| 82 | 82 | if (!is_object($settings)) { |
| 83 | 83 | $settings = $this->getSettings(); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $this->settings = $settings; |
| 86 | 86 | } |
| 87 | 87 | foreach ($settings->fields as $field) { |
| 88 | - $method = 'delete' . $this->toCamel($field->field); |
|
| 88 | + $method = 'delete'.$this->toCamel($field->field); |
|
| 89 | 89 | $this->{$method}(); |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | return str_replace(' ', '', ucwords(str_replace('_', ' ', $field))); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - #[\Override] |
|
| 97 | + #[\Override ] |
|
| 98 | 98 | public function getProviderId(): string { |
| 99 | 99 | $id = self::deriveIdFromFqcn(static::class); |
| 100 | 100 | if ($id === null) { |
| 101 | - throw new \LogicException('Cannot derive gateway id from FQCN: ' . static::class); |
|
| 101 | + throw new \LogicException('Cannot derive gateway id from FQCN: '.static::class); |
|
| 102 | 102 | } |
| 103 | 103 | return $id; |
| 104 | 104 | } |
@@ -20,35 +20,35 @@ 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 | /** |
| 48 | 48 | * @return string |
| 49 | 49 | */ |
| 50 | 50 | private static function keyFromFieldName(string $id, string $fieldName):string { |
| 51 | - return $id . '_' . $fieldName; |
|
| 51 | + return $id.'_'.$fieldName; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | return static::keyFromFieldName($settings->id, $fieldName); |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | - throw new ConfigurationException('Invalid configuration field: ' . $fieldName . ', check SCHEMA at ' . static::class); |
|
| 65 | + throw new ConfigurationException('Invalid configuration field: '.$fieldName.', check SCHEMA at '.static::class); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |