| Conditions | 12 |
| Paths | 62 |
| Total Lines | 51 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 84 | public function process(ServerRequestInterface $request, DelegateInterface $delegate) |
||
| 85 | { |
||
| 86 | try { |
||
| 87 | $authorization = $this->authorizationFactory->createAuthorizationFromRequest($request); |
||
| 88 | $authorization = $this->userAccountDiscoveryManager->find($request, $authorization); |
||
| 89 | |||
| 90 | if (null === $authorization->getUserAccount()) { |
||
| 91 | return $this->redirectToLoginPage($authorization, $request); |
||
| 92 | } |
||
| 93 | |||
| 94 | $authorization = $this->beforeConsentScreenManager->process($request, $authorization); |
||
| 95 | |||
| 96 | return $this->processConsentScreen($request, $authorization); |
||
| 97 | } catch (OAuth2Exception $e) { |
||
| 98 | $data = $e->getData(); |
||
| 99 | if (array_key_exists('authorization', $data)) { |
||
| 100 | $authorization = $data['authorization']; |
||
| 101 | unset($data['authorization']); |
||
| 102 | $redirectUri = $authorization->getRedirectUri(); |
||
| 103 | $responseMode = $authorization->getResponseMode(); |
||
| 104 | if (null !== $redirectUri && null !== $responseMode) { |
||
| 105 | $data['redirect_uri'] = $redirectUri; |
||
| 106 | $data['response_mode'] = $responseMode; |
||
| 107 | throw new OAuth2Exception(302, $data, $e); |
||
| 108 | } |
||
| 109 | } |
||
| 110 | throw $e; |
||
| 111 | } catch (Exception\ProcessAuthorizationException $e) { |
||
| 112 | $authorization = $e->getAuthorization(); |
||
| 113 | $authorization = $this->afterConsentScreenManager->process($request, $authorization); |
||
| 114 | if ($authorization->isAuthorized() === false) { |
||
| 115 | $this->throwRedirectionException($authorization, OAuth2ResponseFactoryManager::ERROR_ACCESS_DENIED, 'The resource owner denied access to your client.'); |
||
| 116 | } |
||
| 117 | |||
| 118 | $responseTypeProcessor = ResponseTypeProcessor::create($authorization); |
||
| 119 | |||
| 120 | try { |
||
| 121 | $authorization = $responseTypeProcessor->process(); |
||
| 122 | } catch (OAuth2Exception $e) { |
||
| 123 | $this->throwRedirectionException($authorization, $e->getData()['error'], $e->getData()['error_description']); |
||
| 124 | } |
||
| 125 | |||
| 126 | return $this->buildResponse($authorization); |
||
| 127 | } catch (Exception\CreateRedirectionException $e) { |
||
| 128 | $this->throwRedirectionException($e->getAuthorization(), $e->getMessage(), $e->getDescription()); |
||
| 129 | } catch (Exception\ShowConsentScreenException $e) { |
||
| 130 | return $this->processConsentScreen($request, $e->getAuthorization()); |
||
| 131 | } catch (Exception\RedirectToLoginPageException $e) { |
||
| 132 | return $this->redirectToLoginPage($e->getAuthorization(), $request); |
||
| 133 | } |
||
| 134 | } |
||
| 135 | |||
| 186 |