Completed
Push — master ( 7005d1...83c2ec )
by smiley
01:50
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
 
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @codeCoverageIgnore
64 64
 	 */
65
-	public function __destruct(){
66
-		if($this->options->sessionStart){
65
+	public function __destruct() {
66
+		if ($this->options->sessionStart) {
67 67
 			session_write_close();
68 68
 		}
69 69
 	}
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
 	public function storeAccessToken(string $service, AccessToken $token):OAuthStorageInterface{
78 78
 		$token = $token->__toJSON();
79 79
 
80
-		if(isset($_SESSION[$this->sessionVar]) && is_array($_SESSION[$this->sessionVar])){
80
+		if (isset($_SESSION[$this->sessionVar]) && is_array($_SESSION[$this->sessionVar])) {
81 81
 			$_SESSION[$this->sessionVar][$service] = $token;
82 82
 		}
83
-		else{
83
+		else {
84 84
 			$_SESSION[$this->sessionVar] = [$service => $token];
85 85
 		}
86 86
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	public function getAccessToken(string $service):AccessToken{
97 97
 
98
-		if($this->hasAccessToken($service)){
98
+		if ($this->hasAccessToken($service)) {
99 99
 			return (new AccessToken)->__fromJSON($_SESSION[$this->sessionVar][$service]);
100 100
 		}
101 101
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function clearAccessToken(string $service):OAuthStorageInterface{
120 120
 
121
-		if(array_key_exists($service, $_SESSION[$this->sessionVar])){
121
+		if (array_key_exists($service, $_SESSION[$this->sessionVar])) {
122 122
 			unset($_SESSION[$this->sessionVar][$service]);
123 123
 		}
124 124
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function clearAllAccessTokens():OAuthStorageInterface{
132 132
 
133
-		foreach(array_keys($_SESSION[$this->sessionVar]) as $service){
133
+		foreach (array_keys($_SESSION[$this->sessionVar]) as $service) {
134 134
 			unset($_SESSION[$this->sessionVar][$service]); // trigger the memzero destructor
135 135
 		}
136 136
 
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function storeCSRFState(string $service, string $state):OAuthStorageInterface{
149 149
 
150
-		if(isset($_SESSION[$this->stateVar]) && is_array($_SESSION[$this->stateVar])){
150
+		if (isset($_SESSION[$this->stateVar]) && is_array($_SESSION[$this->stateVar])) {
151 151
 			$_SESSION[$this->stateVar][$service] = $state;
152 152
 		}
153
-		else{
153
+		else {
154 154
 			$_SESSION[$this->stateVar] = [$service => $state];
155 155
 		}
156 156
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function getCSRFState(string $service):string{
167 167
 
168
-		if($this->hasCSRFState($service)){
168
+		if ($this->hasCSRFState($service)) {
169 169
 			return $_SESSION[$this->stateVar][$service];
170 170
 		}
171 171
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	public function clearCSRFState(string $service):OAuthStorageInterface{
190 190
 
191
-		if(array_key_exists($service, $_SESSION[$this->stateVar])){
191
+		if (array_key_exists($service, $_SESSION[$this->stateVar])) {
192 192
 			unset($_SESSION[$this->stateVar][$service]);
193 193
 		}
194 194
 
Please login to merge, or discard this patch.