Skip to content

Commit 6ca3a51

Browse files
committed
refactor: removed redundant else statements
1 parent 6eac316 commit 6ca3a51

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/VerifyAccessToken.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@ public function handle($request, Closure $next, ...$scopes)
103103
// Now verify the user provided access token
104104
try {
105105
$result = $this->getIntrospect($bearerToken);
106+
106107
if (!$result['active']) {
107108
throw new InvalidAccessTokenException('Invalid token!');
108-
} else if ($scopes != null) {
109+
}
110+
111+
if ($scopes != null) {
109112
if (!\is_array($scopes)) {
110113
$scopes = [
111114
$scopes,
@@ -116,7 +119,6 @@ public function handle($request, Closure $next, ...$scopes)
116119

117120
if (count($misingScopes = array_diff($scopes, $scopesForToken)) > 0) {
118121
throw new InvalidAccessTokenException('Missing the following required scopes: ' . implode(' ,', $misingScopes));
119-
} else {
120122
}
121123
}
122124
} catch (RequestException $e) {
@@ -125,12 +127,12 @@ public function handle($request, Closure $next, ...$scopes)
125127

126128
if (isset($result['error'])) {
127129
throw new InvalidAccessTokenException($result['error']['title'] ?? 'Invalid token!');
128-
} else {
129-
throw new InvalidAccessTokenException('Invalid token!');
130130
}
131-
} else {
132-
throw new InvalidAccessTokenException($e);
131+
132+
throw new InvalidAccessTokenException('Invalid token!');
133133
}
134+
135+
throw new InvalidAccessTokenException($e);
134136
}
135137

136138
return $next($request);

0 commit comments

Comments
 (0)