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 |
||
56 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
57 | { |
||
58 | try { |
||
59 | $authorization = $this->createAuthorizationFromRequest($request); |
||
60 | $isFullyAuthenticated = null; |
||
61 | $userAccount = $this->userAccountDiscovery->find($isFullyAuthenticated); |
||
62 | if (!\is_bool($isFullyAuthenticated)) { |
||
63 | $isFullyAuthenticated = false; |
||
64 | } |
||
65 | if (null !== $userAccount) { |
||
66 | $authorization->setUserAccount($userAccount, $isFullyAuthenticated); |
||
67 | } |
||
68 | $this->userAccountCheckerManager->check($authorization, $userAccount, $isFullyAuthenticated); |
||
69 | if (null === $userAccount) { |
||
70 | return $this->redirectToLoginPage($request, $authorization); |
||
71 | } |
||
72 | $authorization = $this->extensionManager->processBefore($request, $authorization); |
||
73 | |||
74 | return $this->processConsentScreen($request, $authorization); |
||
75 | } catch (OAuth2AuthorizationException $e) { |
||
76 | throw $e; |
||
77 | } catch (Exception\ProcessAuthorizationException $e) { |
||
78 | $authorization = $e->getAuthorization(); |
||
79 | $authorization = $this->extensionManager->processAfter($request, $authorization); |
||
80 | if (false === $authorization->isAuthorized()) { |
||
81 | $this->throwRedirectionException($authorization, OAuth2Message::ERROR_ACCESS_DENIED, 'The resource owner denied access to your client.'); |
||
82 | } |
||
83 | |||
84 | $responseType = $authorization->getResponseType(); |
||
85 | |||
86 | try { |
||
87 | $authorization = $responseType->preProcess($authorization); |
||
88 | $authorization = $responseType->process($authorization); |
||
89 | } catch (OAuth2Message $e) { |
||
90 | $this->throwRedirectionException($authorization, $e->getMessage(), $e->getErrorDescription()); |
||
91 | } |
||
92 | |||
93 | return $this->buildResponse($authorization); |
||
94 | } catch (Exception\CreateRedirectionException $e) { |
||
95 | $this->throwRedirectionException($e->getAuthorization(), $e->getMessage(), $e->getDescription()); |
||
96 | } catch (Exception\ShowConsentScreenException $e) { |
||
97 | return $this->processConsentScreen($request, $e->getAuthorization()); |
||
98 | } catch (Exception\RedirectToLoginPageException $e) { |
||
99 | return $this->redirectToLoginPage($request, $e->getAuthorization()); |
||
100 | } |
||
101 | } |
||
102 | |||
139 |