Skip to content

Commit 944963e

Browse files
StyleCIBothailwood
authored andcommitted
Apply fixes from StyleCI
1 parent 1b2651e commit 944963e

28 files changed

+242
-257
lines changed

config/config.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@
2121
/************************************************************************
2222
* Client ID provided by Xero when registering your application
2323
************************************************************************/
24-
'client_id' => env('XERO_CLIENT_ID'),
24+
'client_id' => env('XERO_CLIENT_ID'),
2525

2626
/************************************************************************
2727
* Client Secret provided by Xero when registering your application
2828
************************************************************************/
29-
'client_secret' => env('XERO_CLIENT_SECRET'),
29+
'client_secret' => env('XERO_CLIENT_SECRET'),
3030

3131
/************************************************************************
3232
* Webhook signing key provided by Xero when registering webhooks
3333
************************************************************************/
34-
'webhook_signing_key' => env('XERO_WEBHOOK_KEY', ''),
34+
'webhook_signing_key' => env('XERO_WEBHOOK_KEY', ''),
3535

3636
/************************************************************************
3737
* Then scopes you wish to request access to on your token
3838
* https://developer.xero.com/documentation/oauth2/scopes
3939
************************************************************************/
40-
'scopes' => [
40+
'scopes' => [
4141
'openid',
4242
'email',
4343
'profile',
@@ -48,26 +48,26 @@
4848
/************************************************************************
4949
* Url to redirect to upon success
5050
************************************************************************/
51-
'redirect_on_success' => 'xero.auth.success',
51+
'redirect_on_success' => 'xero.auth.success',
5252

5353
/************************************************************************
5454
* Url for Xero to redirect to upon granting access
5555
* Unless you wish to change the default behaviour you should not need to
5656
* change this
5757
************************************************************************/
58-
'redirect_uri' => 'xero.auth.callback',
58+
'redirect_uri' => 'xero.auth.callback',
5959

6060
/************************************************************************
6161
* If the 'redirect_uri' is not a route name, but rather a full url set
6262
* this to true and we won't wrap it in `route()`
6363
************************************************************************/
64-
'redirect_full_url' => false,
64+
'redirect_full_url' => false,
6565

6666
/************************************************************************
6767
* Urls for Xero's Oauth integration, you shouldn't need to change these
6868
************************************************************************/
69-
'url_authorize' => 'https://login.xero.com/identity/connect/authorize',
70-
'url_access_token' => 'https://identity.xero.com/connect/token',
69+
'url_authorize' => 'https://login.xero.com/identity/connect/authorize',
70+
'url_access_token' => 'https://identity.xero.com/connect/token',
7171
'url_resource_owner_details' => 'https://api.xero.com/api.xro/2.0/Organisation',
7272
],
7373

routes/web.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3-
use \Illuminate\Support\Facades\Route;
4-
use \Webfox\Xero\Controllers\AuthorizationController;
5-
use \Webfox\Xero\Controllers\AuthorizationCallbackController;
3+
use Illuminate\Support\Facades\Route;
4+
use Webfox\Xero\Controllers\AuthorizationCallbackController;
5+
use Webfox\Xero\Controllers\AuthorizationController;
66

7-
Route::middleware('web')->group(function() {
7+
Route::middleware('web')->group(function () {
88
Route::get('/xero/auth/authorize', AuthorizationController::class)->name('xero.auth.authorize');
99
Route::get('/xero/auth/callback', AuthorizationCallbackController::class)->name('xero.auth.callback');
1010
});

src/Clients/AccountAPIClient.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44

55
class AccountAPIClient extends BaseClient
66
{
7-
8-
}
7+
}

src/Clients/BaseClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public static function fake(): void
1616

1717
public static function getHttpClient(): Client|Mockery
1818
{
19-
if(self::$httpClient){
19+
if (self::$httpClient) {
2020
return self::$httpClient;
2121
}
2222

2323
return self::$httpClient = new Client();
2424
}
25-
}
25+
}

src/Clients/IdentityAPIClient.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44

55
class IdentityAPIClient extends BaseClient
66
{
7-
8-
}
7+
}

src/Controllers/AuthorizationCallbackController.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
namespace Webfox\Xero\Controllers;
44

5+
use Illuminate\Foundation\Validation\ValidatesRequests;
56
use Illuminate\Http\Request;
6-
use Webfox\Xero\Oauth2Provider;
77
use Illuminate\Routing\Controller;
8-
use XeroAPI\XeroPHP\Api\IdentityApi;
98
use Illuminate\Support\Facades\Event;
10-
use Webfox\Xero\Events\XeroAuthorized;
11-
use Webfox\Xero\OauthCredentialManager;
129
use Illuminate\Support\Facades\Redirect;
13-
use Illuminate\Foundation\Validation\ValidatesRequests;
1410
use Illuminate\Support\Str;
11+
use Webfox\Xero\Events\XeroAuthorized;
1512
use Webfox\Xero\Exceptions\OAuthException;
13+
use Webfox\Xero\Oauth2Provider;
14+
use Webfox\Xero\OauthCredentialManager;
15+
use XeroAPI\XeroPHP\Api\IdentityApi;
1616

1717
class AuthorizationCallbackController extends Controller
1818
{
@@ -24,8 +24,8 @@ public function __invoke(Request $request, OauthCredentialManager $oauth, Identi
2424
$this->validate($request, [
2525
'error' => ['sometimes', 'required', 'string'],
2626
'error_description' => ['required_with:error', 'string'],
27-
'code' => ['required_if:error,null', 'string'],
28-
'state' => ['required', 'string', "in:{$oauth->getState()}"]
27+
'code' => ['required_if:error,null', 'string'],
28+
'state' => ['required', 'string', "in:{$oauth->getState()}"],
2929
]);
3030

3131
if ($request->has('error')) {
@@ -41,16 +41,16 @@ public function __invoke(Request $request, OauthCredentialManager $oauth, Identi
4141
}
4242

4343
$accessToken = $provider->getAccessToken('authorization_code', $request->only('code'));
44-
$identity->getConfig()->setAccessToken((string)$accessToken->getToken());
44+
$identity->getConfig()->setAccessToken((string) $accessToken->getToken());
4545

4646
//Iterate tenants
47-
$tenants = array();
47+
$tenants = [];
4848

4949
foreach ($identity->getConnections() as $c) {
5050
$tenants[] = [
51-
"Id" => $c->getTenantId(),
52-
"Name" => $c->getTenantName(),
53-
"ConnectionId" => $c->getId(),
51+
'Id' => $c->getTenantId(),
52+
'Name' => $c->getTenantName(),
53+
'ConnectionId' => $c->getId(),
5454
];
5555
}
5656

src/Controllers/AuthorizationController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ public function __invoke(Redirector $redirect, OauthCredentialManager $oauth): R
1313
{
1414
return $redirect->to($oauth->getAuthorizationUrl());
1515
}
16-
1716
}

src/Events/XeroAuthorized.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ class XeroAuthorized
1212

1313
public function __construct(public array $data)
1414
{
15-
$this->token = $data['token'];
15+
$this->token = $data['token'];
1616
$this->refresh_token = $data['refresh_token'];
17-
$this->id_token = $data['id_token'];
18-
$this->expires = $data['expires'];
19-
$this->tenants = $data['tenants'];
17+
$this->id_token = $data['id_token'];
18+
$this->expires = $data['expires'];
19+
$this->tenants = $data['tenants'];
2020
}
2121
}

src/Exceptions/OAuthException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public function __construct($message, $code = 0, Throwable $previous = null)
1414

1515
public function __toString()
1616
{
17-
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
17+
return __CLASS__.": [{$this->code}]: {$this->message}\n";
1818
}
1919
}

src/Oauth2CredentialManagers/ArrayStore.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class ArrayStore implements OauthCredentialManager
1313

1414
public function __construct(protected Store $session, protected Oauth2Provider $oauthProvider)
1515
{
16-
1716
}
1817

1918
public function getAccessToken(): string
@@ -31,12 +30,12 @@ public function getTenants(): ?array
3130
return $this->data('tenants');
3231
}
3332

34-
public function getTenantId(int $tenant =0): string
33+
public function getTenantId(int $tenant = 0): string
3534
{
36-
if(!isset($this->data('tenants')[$tenant]))
37-
{
38-
throw new \Exception("No such tenant exists");
35+
if (! isset($this->data('tenants')[$tenant])) {
36+
throw new \Exception('No such tenant exists');
3937
}
38+
4039
return $this->data('tenants')[$tenant]['Id'];
4140
}
4241

@@ -86,11 +85,11 @@ public function refresh(): void
8685
public function store(AccessTokenInterface $token, array $tenants = null): void
8786
{
8887
$this->dataStorage = [
89-
'token' => $token->getToken(),
88+
'token' => $token->getToken(),
9089
'refresh_token' => $token->getRefreshToken(),
91-
'id_token' => $token->getValues()['id_token'],
92-
'expires' => $token->getExpires(),
93-
'tenants' => $tenants ?? $this->getTenants()
90+
'id_token' => $token->getValues()['id_token'],
91+
'expires' => $token->getExpires(),
92+
'tenants' => $tenants ?? $this->getTenants(),
9493
];
9594
}
9695

@@ -102,12 +101,12 @@ public function getUser(): ?array
102101
$decodedToken = $jwt->decode();
103102

104103
return [
105-
'given_name' => $decodedToken->getGivenName(),
104+
'given_name' => $decodedToken->getGivenName(),
106105
'family_name' => $decodedToken->getFamilyName(),
107-
'email' => $decodedToken->getEmail(),
108-
'user_id' => $decodedToken->getXeroUserId(),
109-
'username' => $decodedToken->getPreferredUsername(),
110-
'session_id' => $decodedToken->getGlobalSessionId()
106+
'email' => $decodedToken->getEmail(),
107+
'user_id' => $decodedToken->getXeroUserId(),
108+
'username' => $decodedToken->getPreferredUsername(),
109+
'session_id' => $decodedToken->getGlobalSessionId(),
111110
];
112111
} catch (\Throwable $e) {
113112
return null;
@@ -116,10 +115,10 @@ public function getUser(): ?array
116115

117116
protected function data(string $key = null)
118117
{
119-
if (!$this->exists()) {
118+
if (! $this->exists()) {
120119
throw new \Exception('Xero oauth credentials are missing');
121120
}
122121

123122
return $key === null ? $this->dataStorage : $this->dataStorage[$key] ?? null;
124123
}
125-
}
124+
}

0 commit comments

Comments
 (0)