Passed
Push — master ( ec0c43...fec16b )
by smiley
02:09
created
src/Core/TokenRefresh.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Core;
14 14
 
15
-interface TokenRefresh{
15
+interface TokenRefresh {
16 16
 
17 17
 	/**
18 18
 	 * @param \chillerlan\OAuth\Core\AccessToken|null $token
Please login to merge, or discard this patch.
src/Core/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\OAuthStorageInterface $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->hasCSRFState($this->serviceName)){
31
+		if (empty($state) || !$this->storage->hasCSRFState($this->serviceName)) {
32 32
 			throw new ProviderException('invalid state for '.$this->serviceName);
33 33
 		}
34 34
 
35 35
 		$knownState = $this->storage->getCSRFState($this->serviceName);
36 36
 
37
-		if(!hash_equals($knownState, $state)){
37
+		if (!hash_equals($knownState, $state)) {
38 38
 			throw new ProviderException('invalid CSRF state: '.$this->serviceName.' '.$state);
39 39
 		}
40 40
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	protected function setState(array $params):array {
51 51
 
52
-		if(!isset($params['state'])){
52
+		if (!isset($params['state'])) {
53 53
 			$params['state'] = sha1(random_bytes(256));
54 54
 		}
55 55
 
Please login to merge, or discard this patch.
src/Core/OAuth1Interface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Core;
14 14
 
15
-interface OAuth1Interface extends OAuthInterface{
15
+interface OAuth1Interface extends OAuthInterface {
16 16
 
17 17
 	/**
18 18
 	 * @return \chillerlan\OAuth\Core\AccessToken
Please login to merge, or discard this patch.
src/Core/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\Core;
14 14
 
15
-interface AccessTokenForRefresh{
15
+interface AccessTokenForRefresh {
16 16
 
17 17
 }
Please login to merge, or discard this patch.
src/Core/OAuth2Provider.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @method array setState(array $params)
27 27
  * @method \chillerlan\OAuth\Core\OAuth2Interface checkState(string $state = null)
28 28
  */
29
-abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface{
29
+abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface {
30 30
 
31 31
 	/**
32 32
 	 * @var int
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 	 * @param \Psr\Log\LoggerInterface|null                   $logger
63 63
 	 * @param array                                           $scopes
64 64
 	 */
65
-	public function __construct(HTTPClientInterface $http, OAuthStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null, array $scopes = null){
65
+	public function __construct(HTTPClientInterface $http, OAuthStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null, array $scopes = null) {
66 66
 		parent::__construct($http, $storage, $options, $logger);
67 67
 
68
-		if($scopes !== null){
68
+		if ($scopes !== null) {
69 69
 			$this->scopes = $scopes;
70 70
 		}
71 71
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	public function getAuthURL(array $params = null):string{
80 80
 		$params = $this->getAuthURLParams($params ?? []);
81 81
 
82
-		if($this instanceof CSRFToken){
82
+		if ($this instanceof CSRFToken) {
83 83
 			$params = $this->setState($params);
84 84
 		}
85 85
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	protected function getAuthURLParams(array $params):array {
95 95
 
96 96
 		// this should not be here
97
-		if(isset($params['client_secret'])){
97
+		if (isset($params['client_secret'])) {
98 98
 			unset($params['client_secret']);
99 99
 		}
100 100
 
@@ -116,19 +116,19 @@  discard block
 block discarded – undo
116 116
 	protected function parseTokenResponse(HTTPResponseInterface $response):AccessToken{
117 117
 		$data = $response->json_array;
118 118
 
119
-		if(!is_array($data)){
119
+		if (!is_array($data)) {
120 120
 			throw new ProviderException('unable to parse token response');
121 121
 		}
122 122
 
123
-		foreach(['error_description', 'error'] as $field){
123
+		foreach (['error_description', 'error'] as $field) {
124 124
 
125
-			if(isset($data[$field])){
125
+			if (isset($data[$field])) {
126 126
 				throw new ProviderException('error retrieving access token: "'.$data[$field].'"');
127 127
 			}
128 128
 
129 129
 		}
130 130
 
131
-		if(!isset($data['access_token'])){
131
+		if (!isset($data['access_token'])) {
132 132
 			throw new ProviderException('token missing');
133 133
 		}
134 134
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public function getAccessToken(string $code, string $state = null):AccessToken{
156 156
 
157
-		if($this instanceof CSRFToken){
157
+		if ($this instanceof CSRFToken) {
158 158
 			$this->checkState($state);
159 159
 		}
160 160
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		$token = $this->storage->getAccessToken($this->serviceName);
209 209
 
210 210
 		// attempt to refresh an expired token
211
-		if($this->options->tokenAutoRefresh && $this instanceof TokenRefresh && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN)){
211
+		if ($this->options->tokenAutoRefresh && $this instanceof TokenRefresh && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN)) {
212 212
 			$token = $this->refreshAccessToken($token);
213 213
 		}
214 214
 
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 		$params  = array_merge($query, $params ?? []);
218 218
 		$headers = $headers ?? [];
219 219
 
220
-		if(array_key_exists($this->authMethod, $this::AUTH_METHODS_HEADER)){
220
+		if (array_key_exists($this->authMethod, $this::AUTH_METHODS_HEADER)) {
221 221
 			$headers = array_merge($headers, [
222 222
 				'Authorization' => $this::AUTH_METHODS_HEADER[$this->authMethod].$token->accessToken,
223 223
 			]);
224 224
 		}
225
-		elseif(array_key_exists($this->authMethod, $this::AUTH_METHODS_QUERY)){
225
+		elseif (array_key_exists($this->authMethod, $this::AUTH_METHODS_QUERY)) {
226 226
 			$params[$this::AUTH_METHODS_QUERY[$this->authMethod]] = $token->accessToken;
227 227
 		}
228
-		else{
228
+		else {
229 229
 			throw new ProviderException('invalid auth type');
230 230
 		}
231 231
 
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/Core/OAuth2Interface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Core;
14 14
 
15
-interface OAuth2Interface extends OAuthInterface{
15
+interface OAuth2Interface extends OAuthInterface {
16 16
 
17 17
 	const HEADER_OAUTH              = 0;
18 18
 	const HEADER_BEARER             = 1;
Please login to merge, or discard this patch.
src/Core/ClientCredentials.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Core;
14 14
 
15
-interface ClientCredentials{
15
+interface ClientCredentials {
16 16
 
17 17
 	/**
18 18
 	 * @param array $scopes
Please login to merge, or discard this patch.
src/Core/OAuthProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param \chillerlan\Traits\ContainerInterface           $options
91 91
 	 * @param \Psr\Log\LoggerInterface|null                   $logger
92 92
 	 */
93
-	public function __construct(HTTPClientInterface $http, OAuthStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null){
93
+	public function __construct(HTTPClientInterface $http, OAuthStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null) {
94 94
 		$this->setHTTPClient($http);
95 95
 
96 96
 		$this->storage     = $storage;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
 		$this->serviceName = (new ReflectionClass($this))->getShortName();
101 101
 
102
-		if($this instanceof ApiClientInterface){
102
+		if ($this instanceof ApiClientInterface) {
103 103
 			$this->loadEndpoints();
104 104
 		}
105 105
 
Please login to merge, or discard this patch.
src/Core/OAuth2TokenRefreshTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @property \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
20 20
  * @property \chillerlan\OAuth\OAuthOptions                  $options
21 21
  */
22
-trait OAuth2TokenRefreshTrait{
22
+trait OAuth2TokenRefreshTrait {
23 23
 
24 24
 	/**
25 25
 	 * @param \chillerlan\OAuth\Core\AccessToken $token
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function refreshAccessToken(AccessToken $token = null):AccessToken{
31 31
 
32
-		if($token === null){
32
+		if ($token === null) {
33 33
 			$token = $this->storage->getAccessToken($this->serviceName);
34 34
 		}
35 35
 
36 36
 		$refreshToken = $token->refreshToken;
37 37
 
38
-		if(empty($refreshToken)){
38
+		if (empty($refreshToken)) {
39 39
 
40
-			if(!$this instanceof AccessTokenForRefresh){
40
+			if (!$this instanceof AccessTokenForRefresh) {
41 41
 				throw new ProviderException(sprintf('no refresh token available, token expired [%s]', date('Y-m-d h:i:s A', $token->expires)));
42 42
 			}
43 43
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 			)
54 54
 		);
55 55
 
56
-		if(!$newToken->refreshToken){
56
+		if (!$newToken->refreshToken) {
57 57
 			$newToken->refreshToken = $refreshToken;
58 58
 		}
59 59
 
Please login to merge, or discard this patch.