Passed
Push — master ( 74736c...41514f )
by smiley
02:15
created
src/Storage/SessionStorage.php 1 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\Traits\ContainerInterface;
17 17
 
18
-class SessionStorage extends OAuthStorageAbstract{
18
+class SessionStorage extends OAuthStorageAbstract {
19 19
 
20 20
 	/**
21 21
 	 * @var bool
@@ -37,21 +37,21 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param \chillerlan\Traits\ContainerInterface|null $options
39 39
 	 */
40
-	public function __construct(ContainerInterface $options = null){
40
+	public function __construct(ContainerInterface $options = null) {
41 41
 		parent::__construct($options);
42 42
 
43 43
 		$this->sessionVar = $this->options->sessionTokenVar;
44 44
 		$this->stateVar = $this->options->sessionStateVar;
45 45
 
46
-		if($this->options->sessionStart && !$this->sessionIsActive()){
46
+		if ($this->options->sessionStart && !$this->sessionIsActive()) {
47 47
 			session_start();
48 48
 		}
49 49
 
50
-		if(!isset($_SESSION[$this->sessionVar])){
50
+		if (!isset($_SESSION[$this->sessionVar])) {
51 51
 			$_SESSION[$this->sessionVar] = [];
52 52
 		}
53 53
 
54
-		if(!isset($_SESSION[$this->stateVar])){
54
+		if (!isset($_SESSION[$this->stateVar])) {
55 55
 			$_SESSION[$this->stateVar] = [];
56 56
 		}
57 57
 
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * Destructor.
62 62
 	 */
63
-	public function __destruct(){
64
-		if($this->options->sessionStart){
63
+	public function __destruct() {
64
+		if ($this->options->sessionStart) {
65 65
 			session_write_close();
66 66
 		}
67 67
 	}
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	public function storeAccessToken(string $service, AccessToken $token):OAuthStorageInterface{
76 76
 		$token = $token->__toJSON();
77 77
 
78
-		if(isset($_SESSION[$this->sessionVar]) && is_array($_SESSION[$this->sessionVar])){
78
+		if (isset($_SESSION[$this->sessionVar]) && is_array($_SESSION[$this->sessionVar])) {
79 79
 			$_SESSION[$this->sessionVar][$service] = $token;
80 80
 		}
81
-		else{
81
+		else {
82 82
 			$_SESSION[$this->sessionVar] = [$service => $token];
83 83
 		}
84 84
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function getAccessToken(string $service):AccessToken{
95 95
 
96
-		if($this->hasAccessToken($service)){
96
+		if ($this->hasAccessToken($service)) {
97 97
 			return (new AccessToken)->__fromJSON($_SESSION[$this->sessionVar][$service]);
98 98
 		}
99 99
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function clearAccessToken(string $service):OAuthStorageInterface{
118 118
 
119
-		if(array_key_exists($service, $_SESSION[$this->sessionVar])){
119
+		if (array_key_exists($service, $_SESSION[$this->sessionVar])) {
120 120
 			unset($_SESSION[$this->sessionVar][$service]);
121 121
 		}
122 122
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function clearAllAccessTokens():OAuthStorageInterface{
130 130
 
131
-		foreach(array_keys($_SESSION[$this->sessionVar]) as $service){
131
+		foreach (array_keys($_SESSION[$this->sessionVar]) as $service) {
132 132
 			unset($_SESSION[$this->sessionVar][$service]); // trigger the memzero destructor
133 133
 		}
134 134
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	public function storeCSRFState(string $service, string $state):OAuthStorageInterface{
147 147
 
148
-		if(isset($_SESSION[$this->stateVar]) && is_array($_SESSION[$this->stateVar])){
148
+		if (isset($_SESSION[$this->stateVar]) && is_array($_SESSION[$this->stateVar])) {
149 149
 			$_SESSION[$this->stateVar][$service] = $state;
150 150
 		}
151
-		else{
151
+		else {
152 152
 			$_SESSION[$this->stateVar] = [$service => $state];
153 153
 		}
154 154
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public function getCSRFState(string $service):string{
165 165
 
166
-		if($this->hasCSRFState($service)){
166
+		if ($this->hasCSRFState($service)) {
167 167
 			return $_SESSION[$this->stateVar][$service];
168 168
 		}
169 169
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	public function clearCSRFState(string $service):OAuthStorageInterface{
188 188
 
189
-		if(array_key_exists($service, $_SESSION[$this->stateVar])){
189
+		if (array_key_exists($service, $_SESSION[$this->stateVar])) {
190 190
 			unset($_SESSION[$this->stateVar][$service]);
191 191
 		}
192 192
 
Please login to merge, or discard this patch.