diff options
-rw-r--r-- | .github/workflows/lint.yml | 31 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .nextcloudignore | 1 | ||||
-rw-r--r-- | lib/AppInfo/Application.php | 1 | ||||
-rw-r--r-- | lib/Service/Gateway/SMS/Provider/Ovh.php | 14 | ||||
-rw-r--r-- | lib/Service/Gateway/SMS/Provider/SipGate.php | 9 | ||||
-rw-r--r-- | lib/Service/Gateway/SMS/Provider/SipGateConfig.php | 2 | ||||
-rw-r--r-- | tests/Unit/Service/SetupServiceTest.php | 2 |
8 files changed, 45 insertions, 17 deletions
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..f9769a3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +name: Lint +on: pull_request + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + strategy: + # do not stop on another job's failure + fail-fast: false + matrix: + php-versions: ['7.4', '8.0'] + databases: ['sqlite'] + server-versions: ['stable24'] + + name: php-cs check php${{ matrix.php-versions }} + + steps: + - name: Checkout + uses: actions/checkout@master + + - name: Set up php + uses: shivammathur/setup-php@master + with: + php-version: ${{ matrix.php-versions }} + coverage: none + + - name: Install dependencies + run: composer i + + - name: Run coding standards check + run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 ) @@ -11,4 +11,4 @@ vendor/ /tests/clover.* -.php_cs.cache +.php-cs-fixer.cache
\ No newline at end of file diff --git a/.nextcloudignore b/.nextcloudignore index 4ac9707..589480d 100644 --- a/.nextcloudignore +++ b/.nextcloudignore @@ -8,7 +8,6 @@ /.php-cs-fixer.dist.php /.travis.yml /.tx -/.scrutinizer.yml /build /ci /CONTRIBUTING.md diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index c2c88c7..ad8b0df 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace OCA\TwoFactorGateway\AppInfo; -use OCA\TwoFactorGateway\Capabilities; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; diff --git a/lib/Service/Gateway/SMS/Provider/Ovh.php b/lib/Service/Gateway/SMS/Provider/Ovh.php index 4149f72..68dca01 100644 --- a/lib/Service/Gateway/SMS/Provider/Ovh.php +++ b/lib/Service/Gateway/SMS/Provider/Ovh.php @@ -95,11 +95,11 @@ class Ovh implements IProvider { $this->getTimeDelta(); - $header = $this->getHeader('GET',$this->attrs['endpoint'].'/sms'); - $response = $this->client->get($this->attrs['endpoint'].'/sms',[ + $header = $this->getHeader('GET', $this->attrs['endpoint'].'/sms'); + $response = $this->client->get($this->attrs['endpoint'].'/sms', [ 'headers' => $header, ]); - $smsServices = json_decode($response->getBody(),true); + $smsServices = json_decode($response->getBody(), true); $smsAccountFound = false; foreach ($smsServices as $smsService) { @@ -123,12 +123,12 @@ class Ovh implements IProvider { ]; $body = json_encode($content); - $header = $this->getHeader('POST',$this->attrs['endpoint']."/sms/$smsAccount/jobs",$body); - $response = $this->client->post($this->attrs['endpoint']."/sms/$smsAccount/jobs",[ + $header = $this->getHeader('POST', $this->attrs['endpoint']."/sms/$smsAccount/jobs", $body); + $response = $this->client->post($this->attrs['endpoint']."/sms/$smsAccount/jobs", [ 'headers' => $header, 'json' => $content, ]); - $resultPostJob = json_decode($response->getBody(),true); + $resultPostJob = json_decode($response->getBody(), true); if (count($resultPostJob["validReceivers"]) === 0) { throw new SmsTransmissionException("Bad receiver $identifier"); @@ -168,7 +168,7 @@ 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 = [ diff --git a/lib/Service/Gateway/SMS/Provider/SipGate.php b/lib/Service/Gateway/SMS/Provider/SipGate.php index b1931ea..3d18ad5 100644 --- a/lib/Service/Gateway/SMS/Provider/SipGate.php +++ b/lib/Service/Gateway/SMS/Provider/SipGate.php @@ -63,10 +63,10 @@ class SipGate implements IProvider { 'Accept' => 'application/json', ], 'json' => [ - "smsId" => $webSmsExtension, - "message" => $message, - "recipient" => $identifier, - "sendAt" => null, + "smsId" => $webSmsExtension, + "message" => $message, + "recipient" => $identifier, + "sendAt" => null, ], ]); } catch (Exception $ex) { @@ -80,5 +80,4 @@ class SipGate implements IProvider { public function getConfig(): IProviderConfig { return $this->config; } - } diff --git a/lib/Service/Gateway/SMS/Provider/SipGateConfig.php b/lib/Service/Gateway/SMS/Provider/SipGateConfig.php index d61532c..274bd85 100644 --- a/lib/Service/Gateway/SMS/Provider/SipGateConfig.php +++ b/lib/Service/Gateway/SMS/Provider/SipGateConfig.php @@ -31,7 +31,7 @@ class SipGateConfig implements IProviderConfig { private const expected = [ 'sipgate_token_id', 'sipgate_access_token', - 'sipgate_web_sms_extension', + 'sipgate_web_sms_extension', ]; /** @var IConfig */ diff --git a/tests/Unit/Service/SetupServiceTest.php b/tests/Unit/Service/SetupServiceTest.php index 5f5612e..5e9f090 100644 --- a/tests/Unit/Service/SetupServiceTest.php +++ b/tests/Unit/Service/SetupServiceTest.php @@ -131,7 +131,7 @@ class SetupServiceTest extends TestCase { ->method('enableProviderFor'); $this->expectException(Exception::class); - $this->setupService->finishSetup($user, 'telegram','123456'); + $this->setupService->finishSetup($user, 'telegram', '123456'); } public function testFinishSetupWithWrongVerificationNumber() { |