Passed
Push — master ( bfbe67...f82459 )
by smiley
01:50
created
examples/OAuth1Testprovider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 /**
18 18
  *
19 19
  */
20
-class OAuth1Testprovider extends OAuth1Provider{
20
+class OAuth1Testprovider extends OAuth1Provider {
21 21
 
22 22
 	protected $apiURL          = 'https://api.example.com';
23 23
 	protected $requestTokenURL = 'https://example.com/oauth/request_token';
Please login to merge, or discard this patch.
src/Storage/DBTokenStorage.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use chillerlan\OAuth\Token;
17 17
 use chillerlan\Traits\ContainerInterface;
18 18
 
19
-class DBTokenStorage extends TokenStorageAbstract{
19
+class DBTokenStorage extends TokenStorageAbstract {
20 20
 
21 21
 	/**
22 22
 	 * @var \chillerlan\Database\Database
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @throws \chillerlan\OAuth\Storage\TokenStorageException
33 33
 	 */
34
-	public function __construct(ContainerInterface $options, Database $db){
34
+	public function __construct(ContainerInterface $options, Database $db) {
35 35
 		parent::__construct($options);
36 36
 
37
-		if(!$this->options->dbTokenTable || !$this->options->dbProviderTable){
37
+		if (!$this->options->dbTokenTable || !$this->options->dbProviderTable) {
38 38
 			throw new TokenStorageException('invalid table config');
39 39
 		}
40 40
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	public function storeAccessToken(string $service, Token $token):TokenStorageInterface{
63 63
 		$providers = $this->getProviders();
64 64
 
65
-		if(empty($providers) || !isset($providers[$service])){
65
+		if (empty($providers) || !isset($providers[$service])) {
66 66
 			throw new TokenStorageException('unknown service');
67 67
 		}
68 68
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 			$this->options->dbTokenTableExpires    => $token->expires,
74 74
 		];
75 75
 
76
-		if($this->hasAccessToken($service) === true){
76
+		if ($this->hasAccessToken($service) === true) {
77 77
 			$this->db->update
78 78
 				->table($this->options->dbTokenTable)
79 79
 				->set($values)
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			->where($this->options->dbTokenTableLabel, $this->getLabel($service))
108 108
 			->query();
109 109
 
110
-		if(is_bool($r) || $r->length < 1){
110
+		if (is_bool($r) || $r->length < 1) {
111 111
 			throw new TokenStorageException('token not found');
112 112
 		}
113 113
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 			->where($this->options->dbTokenTableLabel, $this->getLabel($service))
188 188
 			->query();
189 189
 
190
-		if(is_bool($r) || $r->length < 1){
190
+		if (is_bool($r) || $r->length < 1) {
191 191
 			throw new TokenStorageException('state not found');
192 192
 		}
193 193
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			->where($this->options->dbTokenTableLabel, $this->getLabel($service))
208 208
 			->query();
209 209
 
210
-		if(is_bool($r) || $r->length < 1 || empty(trim($r[0]->state))){
210
+		if (is_bool($r) || $r->length < 1 || empty(trim($r[0]->state))) {
211 211
 			return false;
212 212
 		}
213 213
 
Please login to merge, or discard this patch.
src/Storage/MemoryTokenStorage.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 use chillerlan\OAuth\Token;
16 16
 
17
-class MemoryTokenStorage extends TokenStorageAbstract{
17
+class MemoryTokenStorage extends TokenStorageAbstract {
18 18
 
19 19
 	/**
20 20
 	 * @var array
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function getAccessToken(string $service):Token{
48 48
 
49
-		if($this->hasAccessToken($service)){
49
+		if ($this->hasAccessToken($service)) {
50 50
 			return $this->tokens[$service];
51 51
 		}
52 52
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function clearAccessToken(string $service):TokenStorageInterface{
71 71
 
72
-		if(array_key_exists($service, $this->tokens)){
72
+		if (array_key_exists($service, $this->tokens)) {
73 73
 			unset($this->tokens[$service]);
74 74
 		}
75 75
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function clearAllAccessTokens():TokenStorageInterface{
83 83
 
84
-		foreach(array_keys($this->tokens) as $service){
84
+		foreach (array_keys($this->tokens) as $service) {
85 85
 			unset($this->tokens[$service]); // trigger the memzero destructor
86 86
 		}
87 87
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function getCSRFState(string $service):string{
112 112
 
113
-		if($this->hasCSRFState($service)){
113
+		if ($this->hasCSRFState($service)) {
114 114
 			return $this->states[$service];
115 115
 		}
116 116
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public function clearCSRFState(string $service):TokenStorageInterface{
135 135
 
136
-		if(array_key_exists($service, $this->states)){
136
+		if (array_key_exists($service, $this->states)) {
137 137
 			unset($this->states[$service]);
138 138
 		}
139 139
 
Please login to merge, or discard this patch.
src/Providers/OAuthProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,14 +88,14 @@
 block discarded – undo
88 88
 	 * @param \chillerlan\OAuth\Storage\TokenStorageInterface $storage
89 89
 	 * @param \chillerlan\Traits\ContainerInterface           $options
90 90
 	 */
91
-	public function __construct(HTTPClientInterface $http, TokenStorageInterface $storage, ContainerInterface $options){
91
+	public function __construct(HTTPClientInterface $http, TokenStorageInterface $storage, ContainerInterface $options) {
92 92
 		$this->setHTTPClient($http);
93 93
 
94 94
 		$this->storage     = $storage;
95 95
 		$this->options     = $options;
96 96
 		$this->serviceName = (new ReflectionClass($this))->getShortName();
97 97
 
98
-		if($this instanceof ApiClientInterface){
98
+		if ($this instanceof ApiClientInterface) {
99 99
 			$this->loadEndpoints();
100 100
 		}
101 101
 
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->getAccessToken($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/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->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.
examples/oauth-example-common.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
 ];
60 60
 
61 61
 /** @var \chillerlan\Traits\ContainerInterface $options */
62
-$options = new class($options_arr) extends OAuthOptions{
62
+$options = new class($options_arr) extends OAuthOptions {
63 63
 	use DatabaseOptionsTrait, LogOptionsTrait;
64 64
 };
65 65
 
66 66
 /** @var \Psr\Log\LoggerInterface $logger */
67 67
 $logger = (new Log)->addInstance(
68
-	new class ($options) extends LogOutputAbstract{
68
+	new class ($options) extends LogOutputAbstract {
69 69
 
70 70
 		protected function __log(string $level, string $message, array $context = null):void{
71 71
 			echo $message.PHP_EOL;
72 72
 
73
-			if(!empty($context)){
73
+			if (!empty($context)) {
74 74
 				echo print_r($context, true).PHP_EOL;
75 75
 			}
76 76
 		}
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 );
81 81
 
82 82
 /** @var \chillerlan\HTTP\HTTPClientInterface $http */
83
-$http = new class($options) extends HTTPClientAbstract{
83
+$http = new class($options) extends HTTPClientAbstract {
84 84
 	use LogTrait;
85 85
 
86 86
 	protected $client;
87 87
 
88
-	public function __construct(ContainerInterface $options){
88
+	public function __construct(ContainerInterface $options) {
89 89
 		parent::__construct($options);
90 90
 		$this->client = new TinyCurlClient($this->options, new Request($this->options));
91 91
 	}
Please login to merge, or discard this patch.