Conditions | 12 |
Paths | 62 |
Total Lines | 53 |
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, RequestHandlerInterface $requestHandler) |
||
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 | |||
108 | throw new OAuth2Exception(302, $data, $e); |
||
109 | } |
||
110 | } |
||
111 | |||
112 | throw $e; |
||
113 | } catch (Exception\ProcessAuthorizationException $e) { |
||
114 | $authorization = $e->getAuthorization(); |
||
115 | $authorization = $this->afterConsentScreenManager->process($request, $authorization); |
||
116 | if ($authorization->isAuthorized() === false) { |
||
117 | $this->throwRedirectionException($authorization, OAuth2ResponseFactoryManager::ERROR_ACCESS_DENIED, 'The resource owner denied access to your client.'); |
||
118 | } |
||
119 | |||
120 | $responseTypeProcessor = ResponseTypeProcessor::create($authorization); |
||
121 | |||
122 | try { |
||
123 | $authorization = $responseTypeProcessor->process(); |
||
124 | } catch (OAuth2Exception $e) { |
||
125 | $this->throwRedirectionException($authorization, $e->getData()['error'], $e->getData()['error_description']); |
||
126 | } |
||
127 | |||
128 | return $this->buildResponse($authorization); |
||
129 | } catch (Exception\CreateRedirectionException $e) { |
||
130 | $this->throwRedirectionException($e->getAuthorization(), $e->getMessage(), $e->getDescription()); |
||
131 | } catch (Exception\ShowConsentScreenException $e) { |
||
132 | return $this->processConsentScreen($request, $e->getAuthorization()); |
||
133 | } catch (Exception\RedirectToLoginPageException $e) { |
||
134 | return $this->redirectToLoginPage($e->getAuthorization(), $request); |
||
135 | } |
||
136 | } |
||
137 | |||
187 |