Completed
Push — master ( dae459...74736c )
by smiley
02:06
created
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.
src/Storage/TokenStorageAbstract.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param \chillerlan\Traits\ContainerInterface|null $options
35 35
 	 * @param \Psr\Log\LoggerInterface|null              $logger
36 36
 	 */
37
-	public function __construct(ContainerInterface $options = null, LoggerInterface $logger = null){
37
+	public function __construct(ContainerInterface $options = null, LoggerInterface $logger = null) {
38 38
 		$this->options = $options ?? new OAuthOptions;
39 39
 		$this->logger  = $logger ?? new NullLogger;
40 40
 	}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 		unset($token);
51 51
 
52
-		if($this->options->useEncryption === true){
52
+		if ($this->options->useEncryption === true) {
53 53
 			return $this->encrypt($data);
54 54
 		}
55 55
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public function fromStorage(string $data):Token{
65 65
 
66
-		if($this->options->useEncryption === true){
66
+		if ($this->options->useEncryption === true) {
67 67
 			$data = $this->decrypt($data);
68 68
 		}
69 69
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	protected function encrypt(string &$data):string {
80 80
 
81
-		if(function_exists('sodium_crypto_secretbox')){
81
+		if (function_exists('sodium_crypto_secretbox')) {
82 82
 			$box = sodium_crypto_secretbox($data, $this::TOKEN_NONCE, sodium_hex2bin($this->options->storageCryptoKey));
83 83
 
84 84
 			sodium_memzero($data);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	protected function decrypt(string $box):string {
99 99
 
100
-		if(function_exists('sodium_crypto_secretbox_open')){
100
+		if (function_exists('sodium_crypto_secretbox_open')) {
101 101
 			return sodium_crypto_secretbox_open(sodium_hex2bin($box), $this::TOKEN_NONCE, sodium_hex2bin($this->options->storageCryptoKey));
102 102
 		}
103 103
 
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
@@ -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, TokenStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null){
93
+	public function __construct(HTTPClientInterface $http, TokenStorageInterface $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/Storage/TokenStorageInterface.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 \Psr\Log\LoggerInterface $logger
20 20
  * @method setLogger(\Psr\Log\LoggerInterface $logger)
21 21
  */
22
-interface TokenStorageInterface{
22
+interface TokenStorageInterface {
23 23
 
24 24
 	/**
25 25
 	 * @param string                  $service
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
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
  * from \chillerlan\Traits\Classloader
27 27
  * @method mixed loadClass(string $class, string $type = null, ...$params)
28 28
  */
29
-interface OAuthInterface{
29
+interface OAuthInterface {
30 30
 
31 31
 	/**
32 32
 	 * @param array $params
Please login to merge, or discard this patch.
examples/oauth-example-common.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  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
 
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 $logger->addInstance(new ConsoleLog($options), 'console');
68 68
 
69 69
 /** @var \chillerlan\HTTP\HTTPClientInterface $http */
70
-$http = new class($options) extends HTTPClientAbstract{
70
+$http = new class($options) extends HTTPClientAbstract {
71 71
 
72 72
 	protected $client;
73 73
 
74
-	public function __construct(ContainerInterface $options){
74
+	public function __construct(ContainerInterface $options) {
75 75
 		parent::__construct($options);
76 76
 		$this->client = new TinyCurlClient($this->options, new Request($this->options));
77 77
 	}
Please login to merge, or discard this patch.