Conditions | 6 |
Paths | 10 |
Total Lines | 56 |
Code Lines | 31 |
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 |
||
62 | public function handleAuthorizationRequest(AuthorizationEndpoint $authorizationEndpoint, array $requestData): array |
||
63 | { |
||
64 | if (!$authorizationEndpoint instanceof \OAuth2\Extensions\OpenID\Endpoints\AuthorizationEndpoint) { |
||
65 | throw new \InvalidArgumentException(); |
||
66 | } |
||
67 | |||
68 | $result = []; |
||
69 | $idTokenClaims = []; |
||
70 | $responseTypes = explode(' ', $requestData['response_type']); |
||
71 | if (in_array('code', $responseTypes)) { |
||
72 | // $resourceOwnerClaims = $authorizationEndpoint->getResourceOwner()->getClaims($authorizationEndpoint->getScopes()); |
||
73 | // $idTokenTokenEndpoint = $this->idTokenManager->issueIdToken( |
||
74 | // $authorizationEndpoint->getClient(), |
||
75 | // $authorizationEndpoint->getResourceOwner(), |
||
76 | // $resourceOwnerClaims |
||
77 | // ); |
||
78 | |||
79 | $authorizationCode = $this->authorizationCodeStorage->generate( |
||
80 | implode(' ', $authorizationEndpoint->getScopes()), |
||
81 | $authorizationEndpoint->getClient()->getIdentifier(), |
||
82 | $authorizationEndpoint->getResourceOwner()->getIdentifier(), |
||
83 | $requestData['scope'] ?? null, |
||
84 | $requestData['redirect_uri'] ?? null |
||
85 | // $idTokenTokenEndpoint |
||
86 | ); |
||
87 | |||
88 | if (!$authorizationCode instanceof AuthorizationCodeInterface) { |
||
89 | throw new \InvalidArgumentException(); |
||
90 | } |
||
91 | |||
92 | $idTokenClaims['c_hash'] = $this->idTokenManager->getCodeHash( |
||
93 | $authorizationEndpoint->getClient(), $authorizationCode); |
||
94 | $result['code'] = $authorizationCode->getCode(); |
||
95 | } |
||
96 | |||
97 | if (in_array('token', $responseTypes)) { |
||
98 | $accessToken = $this->accessTokenStorage->generate( |
||
99 | implode(' ', $authorizationEndpoint->getScopes()), |
||
100 | $authorizationEndpoint->getClient()->getIdentifier(), |
||
101 | $authorizationEndpoint->getResourceOwner()->getIdentifier() |
||
102 | ); |
||
103 | |||
104 | $idTokenClaims['at_hash'] = $this->idTokenManager->getAccessTokenHash( |
||
105 | $authorizationEndpoint->getClient(), $accessToken); |
||
106 | $result['access_token'] = $accessToken->getToken(); |
||
107 | } |
||
108 | |||
109 | if (in_array('id_token', $responseTypes)) { |
||
110 | $result['id_token'] = $this->idTokenManager->issueIdToken( |
||
111 | $authorizationEndpoint->getClient(), |
||
112 | $authorizationEndpoint->getResourceOwner(), |
||
113 | $idTokenClaims |
||
114 | ); |
||
115 | } |
||
116 | |||
117 | return $result; |
||
118 | } |
||
139 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.