From f88961eddd0efee189088b39c1252f934e231cda Mon Sep 17 00:00:00 2001 From: Iman Date: Thu, 23 Nov 2017 21:26:39 +0330 Subject: [PATCH] flatten code --- src/AuthorizationServer.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/AuthorizationServer.php b/src/AuthorizationServer.php index c375af47..69c16954 100644 --- a/src/AuthorizationServer.php +++ b/src/AuthorizationServer.php @@ -178,17 +178,19 @@ class AuthorizationServer implements EmitterAwareInterface public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response) { foreach ($this->enabledGrantTypes as $grantType) { - if ($grantType->canRespondToAccessTokenRequest($request)) { - $tokenResponse = $grantType->respondToAccessTokenRequest( - $request, - $this->getResponseType(), - $this->grantTypeAccessTokenTTL[$grantType->getIdentifier()] - ); - - if ($tokenResponse instanceof ResponseTypeInterface) { - return $tokenResponse->generateHttpResponse($response); - } + if (!$grantType->canRespondToAccessTokenRequest($request)) { + continue; } + $tokenResponse = $grantType->respondToAccessTokenRequest( + $request, + $this->getResponseType(), + $this->grantTypeAccessTokenTTL[$grantType->getIdentifier()] + ); + + if ($tokenResponse instanceof ResponseTypeInterface) { + return $tokenResponse->generateHttpResponse($response); + } + } throw OAuthServerException::unsupportedGrantType();