| Conditions | 11 |
| Paths | 218 |
| Total Lines | 46 |
| 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 |
||
| 80 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 81 | { |
||
| 82 | try { |
||
| 83 | $authorization = $this->createAuthorizationFromRequest($request); |
||
| 84 | $isFullyAuthenticated = null; |
||
| 85 | $userAccount = $this->userAccountDiscovery->find($isFullyAuthenticated); |
||
| 86 | if (!\is_bool($isFullyAuthenticated)) { |
||
| 87 | $isFullyAuthenticated = false; |
||
| 88 | } |
||
| 89 | if (null !== $userAccount) { |
||
| 90 | $authorization = $authorization->withUserAccount($userAccount, $isFullyAuthenticated); |
||
| 91 | } |
||
| 92 | $this->userAccountCheckerManager->check($authorization, $userAccount, $isFullyAuthenticated); |
||
| 93 | if (null === $userAccount) { |
||
| 94 | return $this->redirectToLoginPage($request, $authorization); |
||
| 95 | } |
||
| 96 | $authorization = $this->consentScreenExtensionManager->processBefore($request, $authorization); |
||
| 97 | |||
| 98 | return $this->processConsentScreen($request, $authorization); |
||
| 99 | } catch (OAuth2AuthorizationException $e) { |
||
| 100 | throw $e; |
||
| 101 | } catch (Exception\ProcessAuthorizationException $e) { |
||
| 102 | $authorization = $e->getAuthorization(); |
||
| 103 | $authorization = $this->consentScreenExtensionManager->processAfter($request, $authorization); |
||
| 104 | if (false === $authorization->isAuthorized()) { |
||
| 105 | $this->throwRedirectionException($authorization, OAuth2Message::ERROR_ACCESS_DENIED, 'The resource owner denied access to your client.'); |
||
| 106 | } |
||
| 107 | |||
| 108 | $responseType = $authorization->getResponseType(); |
||
| 109 | |||
| 110 | try { |
||
| 111 | $authorization = $responseType->preProcess($authorization); |
||
| 112 | $authorization = $responseType->process($authorization); |
||
| 113 | } catch (OAuth2Message $e) { |
||
| 114 | $this->throwRedirectionException($authorization, $e->getMessage(), $e->getErrorDescription()); |
||
| 115 | } |
||
| 116 | |||
| 117 | return $this->buildResponse($authorization); |
||
| 118 | } catch (Exception\CreateRedirectionException $e) { |
||
| 119 | $this->throwRedirectionException($e->getAuthorization(), $e->getMessage(), $e->getDescription()); |
||
| 120 | } catch (Exception\ShowConsentScreenException $e) { |
||
| 121 | return $this->processConsentScreen($request, $e->getAuthorization()); |
||
| 122 | } catch (Exception\RedirectToLoginPageException $e) { |
||
| 123 | return $this->redirectToLoginPage($request, $e->getAuthorization()); |
||
| 124 | } |
||
| 125 | } |
||
| 126 | |||
| 163 |