Completed
Branch master (c6d423)
by smiley
02:44 queued 47s
created
src/Providers/OAuth2Provider.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @method array setState(array $params)
26 26
  * @method \chillerlan\OAuth\Providers\OAuth2Interface checkState(string $state = null)
27 27
  */
28
-abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface{
28
+abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface {
29 29
 
30 30
 	/**
31 31
 	 * @var int
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @param \chillerlan\Traits\ContainerInterface           $options
61 61
 	 * @param array                                           $scopes
62 62
 	 */
63
-	public function __construct(HTTPClientInterface $http, TokenStorageInterface $storage, ContainerInterface $options, array $scopes = null){
63
+	public function __construct(HTTPClientInterface $http, TokenStorageInterface $storage, ContainerInterface $options, array $scopes = null) {
64 64
 		parent::__construct($http, $storage, $options);
65 65
 
66 66
 		$this->scopes = $scopes ?? [];
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	public function getAuthURL(array $params = null):string{
75 75
 		$params = $this->getAuthURLParams($params ?? []);
76 76
 
77
-		if($this instanceof CSRFToken){
77
+		if ($this instanceof CSRFToken) {
78 78
 			$params = $this->setState($params);
79 79
 		}
80 80
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	protected function getAuthURLParams(array $params):array {
90 90
 
91 91
 		// this should not be here
92
-		if(isset($params['client_secret'])){
92
+		if (isset($params['client_secret'])) {
93 93
 			unset($params['client_secret']);
94 94
 		}
95 95
 
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
 	protected function parseTokenResponse(HTTPResponseInterface $response):Token{
112 112
 		$data = $response->json_array;
113 113
 
114
-		if(!is_array($data)){
114
+		if (!is_array($data)) {
115 115
 			throw new ProviderException('unable to parse token response');
116 116
 		}
117 117
 
118
-		foreach(['error_description', 'error'] as $field){
118
+		foreach (['error_description', 'error'] as $field) {
119 119
 
120
-			if(isset($data[$field])){
120
+			if (isset($data[$field])) {
121 121
 				throw new ProviderException('error retrieving access token: "'.$data[$field].'"');
122 122
 			}
123 123
 
124 124
 		}
125 125
 
126
-		if(!isset($data['access_token'])){
126
+		if (!isset($data['access_token'])) {
127 127
 			throw new ProviderException('token missing');
128 128
 		}
129 129
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	public function getAccessToken(string $code, string $state = null):Token{
151 151
 
152
-		if($this instanceof CSRFToken){
152
+		if ($this instanceof CSRFToken) {
153 153
 			$this->checkState($state);
154 154
 		}
155 155
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		$token = $this->storage->retrieveAccessToken($this->serviceName);
204 204
 
205 205
 		// attempt to refresh an expired token
206
-		if($this->options->tokenAutoRefresh && $this instanceof TokenRefresh && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN)){
206
+		if ($this->options->tokenAutoRefresh && $this instanceof TokenRefresh && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN)) {
207 207
 			$token = $this->refreshAccessToken($token);
208 208
 		}
209 209
 
@@ -212,15 +212,15 @@  discard block
 block discarded – undo
212 212
 		$params  = array_merge($query, $params ?? []);
213 213
 		$headers = $headers ?? [];
214 214
 
215
-		if(array_key_exists($this->authMethod, $this::AUTH_METHODS_HEADER)){
215
+		if (array_key_exists($this->authMethod, $this::AUTH_METHODS_HEADER)) {
216 216
 			$headers = array_merge($headers, [
217 217
 				'Authorization' => $this::AUTH_METHODS_HEADER[$this->authMethod].$token->accessToken,
218 218
 			]);
219 219
 		}
220
-		elseif(array_key_exists($this->authMethod, $this::AUTH_METHODS_QUERY)){
220
+		elseif (array_key_exists($this->authMethod, $this::AUTH_METHODS_QUERY)) {
221 221
 			$params[$this::AUTH_METHODS_QUERY[$this->authMethod]] = $token->accessToken;
222 222
 		}
223
-		else{
223
+		else {
224 224
 			throw new ProviderException('invalid auth type');
225 225
 		}
226 226
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -216,11 +216,9 @@
 block discarded – undo
216 216
 			$headers = array_merge($headers, [
217 217
 				'Authorization' => $this::AUTH_METHODS_HEADER[$this->authMethod].$token->accessToken,
218 218
 			]);
219
-		}
220
-		elseif(array_key_exists($this->authMethod, $this::AUTH_METHODS_QUERY)){
219
+		} elseif(array_key_exists($this->authMethod, $this::AUTH_METHODS_QUERY)){
221 220
 			$params[$this::AUTH_METHODS_QUERY[$this->authMethod]] = $token->accessToken;
222
-		}
223
-		else{
221
+		} else{
224 222
 			throw new ProviderException('invalid auth type');
225 223
 		}
226 224
 
Please login to merge, or discard this patch.
src/Providers/OAuth2TokenRefreshTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @property \chillerlan\OAuth\Storage\TokenStorageInterface $storage
22 22
  * @property \chillerlan\OAuth\OAuthOptions $options
23 23
  */
24
-trait OAuth2TokenRefreshTrait{
24
+trait OAuth2TokenRefreshTrait {
25 25
 
26 26
 	/**
27 27
 	 * @param \chillerlan\OAuth\Token $token
@@ -31,15 +31,15 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function refreshAccessToken(Token $token = null):Token{
33 33
 
34
-		if($token === null){
34
+		if ($token === null) {
35 35
 			$token = $this->storage->retrieveAccessToken($this->serviceName);
36 36
 		}
37 37
 
38 38
 		$refreshToken = $token->refreshToken;
39 39
 
40
-		if(empty($refreshToken)){
40
+		if (empty($refreshToken)) {
41 41
 
42
-			if(!$this instanceof AccessTokenForRefresh){
42
+			if (!$this instanceof AccessTokenForRefresh) {
43 43
 				throw new ProviderException(sprintf('no refresh token available, token expired [%s]', date('Y-m-d h:i:s A', $token->expires)));
44 44
 			}
45 45
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			)
56 56
 		);
57 57
 
58
-		if(!$newToken->refreshToken){
58
+		if (!$newToken->refreshToken) {
59 59
 			$newToken->refreshToken = $refreshToken;
60 60
 		}
61 61
 
Please login to merge, or discard this patch.
src/Providers/AccessTokenForRefresh.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Providers;
14 14
 
15
-interface AccessTokenForRefresh{
15
+interface AccessTokenForRefresh {
16 16
 
17 17
 }
Please login to merge, or discard this patch.
src/Providers/OAuth2ClientCredentialsTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
  * @property string $accessTokenURL
22 22
  * @property \chillerlan\OAuth\Storage\TokenStorageInterface $storage
23 23
  */
24
-trait OAuth2ClientCredentialsTrait{
24
+trait OAuth2ClientCredentialsTrait {
25 25
 
26 26
 	/**
27 27
 	 * @param array $scopes
Please login to merge, or discard this patch.
src/Providers/CSRFToken.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Providers;
14 14
 
15
-interface CSRFToken{
15
+interface CSRFToken {
16 16
 
17 17
 }
Please login to merge, or discard this patch.
src/Providers/CSRFTokenTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  * @property string $serviceName
19 19
  * @property \chillerlan\OAuth\Storage\TokenStorageInterface $storage
20 20
  */
21
-trait CSRFTokenTrait{
21
+trait CSRFTokenTrait {
22 22
 
23 23
 	/**
24 24
 	 * @param string|null $state
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	protected function checkState(string $state = null):OAuth2Interface{
30 30
 
31
-		if(empty($state) || !$this->storage->hasAuthorizationState($this->serviceName)){
31
+		if (empty($state) || !$this->storage->hasAuthorizationState($this->serviceName)) {
32 32
 			throw new ProviderException('invalid state for '.$this->serviceName);
33 33
 		}
34 34
 
35 35
 		$knownState = $this->storage->retrieveAuthorizationState($this->serviceName);
36 36
 
37
-		if(!hash_equals($knownState, $state)){
37
+		if (!hash_equals($knownState, $state)) {
38 38
 			throw new ProviderException('invalid authorization state: '.$this->serviceName.' '.$state);
39 39
 		}
40 40
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	protected function setState(array $params):array {
50 50
 
51
-		if(!isset($params['state'])){
51
+		if (!isset($params['state'])) {
52 52
 			$params['state'] = sha1(random_bytes(256));
53 53
 		}
54 54
 
Please login to merge, or discard this patch.
src/Providers/ProviderException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,4 +14,4 @@
 block discarded – undo
14 14
 
15 15
 use chillerlan\OAuth\OAuthException;
16 16
 
17
-class ProviderException extends OAuthException{}
17
+class ProviderException extends OAuthException {}
Please login to merge, or discard this patch.
src/Providers/TokenRefresh.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 use chillerlan\OAuth\Token;
16 16
 
17
-interface TokenRefresh{
17
+interface TokenRefresh {
18 18
 
19 19
 	/**
20 20
 	 * @param \chillerlan\OAuth\Token|null $token
Please login to merge, or discard this patch.
src/Providers/OAuthInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
  * @property string $serviceName
20 20
  * @property string $userRevokeURL
21 21
  */
22
-interface OAuthInterface{
22
+interface OAuthInterface {
23 23
 
24 24
 	/**
25 25
 	 * @param array $params
Please login to merge, or discard this patch.