Passed
Push — master ( 18ae99...9ceb2f )
by smiley
01:37
created
src/Storage/OAuthStorageInterface.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\Core\AccessToken;
16 16
 
17
-interface OAuthStorageInterface{
17
+interface OAuthStorageInterface {
18 18
 
19 19
 	/**
20 20
 	 * @param string                             $service
Please login to merge, or discard this patch.
src/Storage/SessionStorage.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,8 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
 		if(isset($_SESSION[$this->sessionVar]) && is_array($_SESSION[$this->sessionVar])){
85 85
 			$_SESSION[$this->sessionVar][$service] = $token;
86
-		}
87
-		else{
86
+		} else{
88 87
 			$_SESSION[$this->sessionVar] = [$service => $token];
89 88
 		}
90 89
 
@@ -153,8 +152,7 @@  discard block
 block discarded – undo
153 152
 
154 153
 		if(isset($_SESSION[$this->stateVar]) && is_array($_SESSION[$this->stateVar])){
155 154
 			$_SESSION[$this->stateVar][$service] = $state;
156
-		}
157
-		else{
155
+		} else{
158 156
 			$_SESSION[$this->stateVar] = [$service => $state];
159 157
 		}
160 158
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use chillerlan\OAuth\Core\AccessToken;
16 16
 use chillerlan\Settings\SettingsContainerInterface;
17 17
 
18
-class SessionStorage extends OAuthStorageAbstract{
18
+class SessionStorage extends OAuthStorageAbstract {
19 19
 
20 20
 	/**
21 21
 	 * @var string
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param \chillerlan\Settings\SettingsContainerInterface|null $options
34 34
 	 */
35
-	public function __construct(SettingsContainerInterface $options = null){
35
+	public function __construct(SettingsContainerInterface $options = null) {
36 36
 		parent::__construct($options);
37 37
 
38 38
 		$this->sessionVar = $this->options->sessionTokenVar;
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 
41 41
 		// Determine if the session has started.
42 42
 		// @link http://stackoverflow.com/a/18542272/1470961
43
-		if($this->options->sessionStart && !(session_status() !== PHP_SESSION_NONE)){
43
+		if ($this->options->sessionStart && !(session_status() !== PHP_SESSION_NONE)) {
44 44
 			session_start();
45 45
 		}
46 46
 
47
-		if(!isset($_SESSION[$this->sessionVar])){
47
+		if (!isset($_SESSION[$this->sessionVar])) {
48 48
 			$_SESSION[$this->sessionVar] = [];
49 49
 		}
50 50
 
51
-		if(!isset($_SESSION[$this->stateVar])){
51
+		if (!isset($_SESSION[$this->stateVar])) {
52 52
 			$_SESSION[$this->stateVar] = [];
53 53
 		}
54 54
 
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @codeCoverageIgnore
61 61
 	 */
62
-	public function __destruct(){
63
-		if($this->options->sessionStart){
62
+	public function __destruct() {
63
+		if ($this->options->sessionStart) {
64 64
 			session_write_close();
65 65
 		}
66 66
 	}
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 	public function storeAccessToken(string $service, AccessToken $token):OAuthStorageInterface{
75 75
 		$token = $token->toJSON();
76 76
 
77
-		if(isset($_SESSION[$this->sessionVar]) && is_array($_SESSION[$this->sessionVar])){
77
+		if (isset($_SESSION[$this->sessionVar]) && is_array($_SESSION[$this->sessionVar])) {
78 78
 			$_SESSION[$this->sessionVar][$service] = $token;
79 79
 		}
80
-		else{
80
+		else {
81 81
 			$_SESSION[$this->sessionVar] = [$service => $token];
82 82
 		}
83 83
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function getAccessToken(string $service):AccessToken{
94 94
 
95
-		if($this->hasAccessToken($service)){
95
+		if ($this->hasAccessToken($service)) {
96 96
 			return (new AccessToken)->fromJSON($_SESSION[$this->sessionVar][$service]);
97 97
 		}
98 98
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function clearAccessToken(string $service):OAuthStorageInterface{
117 117
 
118
-		if(array_key_exists($service, $_SESSION[$this->sessionVar])){
118
+		if (array_key_exists($service, $_SESSION[$this->sessionVar])) {
119 119
 			unset($_SESSION[$this->sessionVar][$service]);
120 120
 		}
121 121
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function clearAllAccessTokens():OAuthStorageInterface{
129 129
 
130
-		foreach(array_keys($_SESSION[$this->sessionVar]) as $service){
130
+		foreach (array_keys($_SESSION[$this->sessionVar]) as $service) {
131 131
 			unset($_SESSION[$this->sessionVar][$service]);
132 132
 		}
133 133
 
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	public function storeCSRFState(string $service, string $state):OAuthStorageInterface{
146 146
 
147
-		if(isset($_SESSION[$this->stateVar]) && is_array($_SESSION[$this->stateVar])){
147
+		if (isset($_SESSION[$this->stateVar]) && is_array($_SESSION[$this->stateVar])) {
148 148
 			$_SESSION[$this->stateVar][$service] = $state;
149 149
 		}
150
-		else{
150
+		else {
151 151
 			$_SESSION[$this->stateVar] = [$service => $state];
152 152
 		}
153 153
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	public function getCSRFState(string $service):string{
164 164
 
165
-		if($this->hasCSRFState($service)){
165
+		if ($this->hasCSRFState($service)) {
166 166
 			return $_SESSION[$this->stateVar][$service];
167 167
 		}
168 168
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	public function clearCSRFState(string $service):OAuthStorageInterface{
187 187
 
188
-		if(array_key_exists($service, $_SESSION[$this->stateVar])){
188
+		if (array_key_exists($service, $_SESSION[$this->stateVar])) {
189 189
 			unset($_SESSION[$this->stateVar][$service]);
190 190
 		}
191 191
 
Please login to merge, or discard this patch.
src/Core/OAuth2TokenRefreshTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * @property \Psr\Http\Message\RequestFactoryInterface       $requestFactory
25 25
  * @property \Psr\Http\Message\StreamFactoryInterface        $streamFactory
26 26
  */
27
-trait OAuth2TokenRefreshTrait{
27
+trait OAuth2TokenRefreshTrait {
28 28
 
29 29
 	/**
30 30
 	 * @param \chillerlan\OAuth\Core\AccessToken $token
@@ -34,15 +34,15 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	public function refreshAccessToken(AccessToken $token = null):AccessToken{
36 36
 
37
-		if($token === null){
37
+		if ($token === null) {
38 38
 			$token = $this->storage->getAccessToken($this->serviceName);
39 39
 		}
40 40
 
41 41
 		$refreshToken = $token->refreshToken;
42 42
 
43
-		if(empty($refreshToken)){
43
+		if (empty($refreshToken)) {
44 44
 
45
-			if(!$this instanceof AccessTokenForRefresh){
45
+			if (!$this instanceof AccessTokenForRefresh) {
46 46
 				throw new ProviderException(sprintf('no refresh token available, token expired [%s]', date('Y-m-d h:i:s A', $token->expires)));
47 47
 			}
48 48
 
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 			->withBody($this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738)))
64 64
 		;
65 65
 
66
-		foreach($this->authHeaders as $header => $value){
66
+		foreach ($this->authHeaders as $header => $value) {
67 67
 			$request = $request->withAddedHeader($header, $value);
68 68
 		}
69 69
 
70 70
 		$newToken = $this->parseTokenResponse($this->http->sendRequest($request));
71 71
 
72
-		if(empty($newToken->refreshToken)){
72
+		if (empty($newToken->refreshToken)) {
73 73
 			$newToken->refreshToken = $refreshToken;
74 74
 		}
75 75
 
Please login to merge, or discard this patch.
src/Core/OAuth2ClientCredentialsTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * @property \Psr\Http\Message\RequestFactoryInterface       $requestFactory
25 25
  * @property \Psr\Http\Message\StreamFactoryInterface        $streamFactory
26 26
  */
27
-trait OAuth2ClientCredentialsTrait{
27
+trait OAuth2ClientCredentialsTrait {
28 28
 
29 29
 	/**
30 30
 	 * @param array $scopes
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	public function getClientCredentialsToken(array $scopes = null):AccessToken{
35 35
 		$params = ['grant_type' => 'client_credentials'];
36 36
 
37
-		if($scopes !== null){
37
+		if ($scopes !== null) {
38 38
 			$params['scope'] = implode($this->scopesDelimiter, $scopes);
39 39
 		}
40 40
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 			->withBody($this->streamFactory->createStream(http_build_query($params, '', '&', PHP_QUERY_RFC1738)))
46 46
 		;
47 47
 
48
-		foreach($this->authHeaders as $header => $value){
48
+		foreach ($this->authHeaders as $header => $value) {
49 49
 			$request = $request->withAddedHeader($header, $value);
50 50
 		}
51 51
 
Please login to merge, or discard this patch.
src/OAuthOptionsTrait.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;
14 14
 
15
-trait OAuthOptionsTrait{
15
+trait OAuthOptionsTrait {
16 16
 
17 17
 	/**
18 18
 	 * @var string
Please login to merge, or discard this patch.
src/Storage/OAuthStorageAbstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use chillerlan\OAuth\{Core\AccessToken, OAuthOptions};
16 16
 use chillerlan\Settings\SettingsContainerInterface;
17 17
 
18
-abstract class OAuthStorageAbstract implements OAuthStorageInterface{
18
+abstract class OAuthStorageAbstract implements OAuthStorageInterface {
19 19
 
20 20
 	/**
21 21
 	 * @var \chillerlan\OAuth\OAuthOptions
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param \chillerlan\Settings\SettingsContainerInterface|null $options
29 29
 	 */
30
-	public function __construct(SettingsContainerInterface $options = null){
30
+	public function __construct(SettingsContainerInterface $options = null) {
31 31
 		$this->options = $options ?? new OAuthOptions;
32 32
 	}
33 33
 
Please login to merge, or discard this patch.
examples/OAuth1Testprovider.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\Core\OAuth1Provider;
16 16
 
17
-class OAuth1Testprovider extends OAuth1Provider{
17
+class OAuth1Testprovider extends OAuth1Provider {
18 18
 
19 19
 	protected $apiURL          = 'https://api.example.com';
20 20
 	protected $requestTokenURL = 'https://example.com/oauth/request_token';
Please login to merge, or discard this patch.
examples/TestEndpoints.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\HTTP\MagicAPI\EndpointMap;
16 16
 
17
-class TestEndpoints extends EndpointMap{
17
+class TestEndpoints extends EndpointMap {
18 18
 
19 19
 	protected $test = [
20 20
 		'path'          => '/test/%1$s',
Please login to merge, or discard this patch.
examples/OAuth2Testprovider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	protected $authURL        = 'https://example.com/oauth2/authorize';
25 25
 	protected $accessTokenURL = 'https://example.com/oauth2/token';
26 26
 	protected $userRevokeURL  = 'https://account.example.com/apps/';
27
-	protected $endpointMap     = TestEndpoints::class;
27
+	protected $endpointMap = TestEndpoints::class;
28 28
 	protected $authHeaders    = ['foo' => 'bar'];
29 29
 	protected $apiHeaders     = ['foo' => 'bar'];
30 30
 
Please login to merge, or discard this patch.