Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 44 |
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 |
||
151 | public function getOAuthProviderOptions(string $providerType, array $config): array |
||
152 | { |
||
153 | $defaults = match ($providerType) { |
||
154 | 'generic' => [ |
||
155 | 'clientId' => $config['client_id'], |
||
156 | 'clientSecret' => $config['client_secret'], |
||
157 | 'urlAuthorize' => $config['urlAuthorize'], |
||
158 | 'urlAccessToken' => $config['urlAccessToken'], |
||
159 | 'urlResourceOwnerDetails' => $config['urlResourceOwnerDetails'], |
||
160 | 'accessTokenMethod' => $config['accessTokenMethod'] ?? null, |
||
161 | 'accessTokenResourceOwnerId' => $config['accessTokenResourceOwnerId'] ?? null, |
||
162 | 'scopeSeparator' => $config['scopeSeparator'] ?? null, |
||
163 | 'responseError' => $config['responseError'] ?? null, |
||
164 | 'responseCode' => $config['responseCode'] ?? null, |
||
165 | 'responseResourceOwnerId' => $config['responseResourceOwnerId'] ?? null, |
||
166 | 'scopes' => $config['scopes'] ?? null, |
||
167 | 'pkceMethod' => $config['pkceMethod'] ?? null, |
||
168 | ], |
||
169 | 'facebook' => [ |
||
170 | 'clientId' => $config['client_id'], |
||
171 | 'clientSecret' => $config['client_secret'], |
||
172 | 'graphApiVersion' => $config['graph_api_version'] ?? null, |
||
173 | ], |
||
174 | 'keycloak' => [ |
||
175 | 'clientId' => $config['client_id'], |
||
176 | 'clientSecret' => $config['client_secret'], |
||
177 | 'authServerUrl' => $config['auth_server_url'], |
||
178 | 'realm' => $config['realm'], |
||
179 | 'version' => $config['version'] ?? null, |
||
180 | 'encryptionAlgorithm' => $config['encryption_algorithm'] ?? null, |
||
181 | 'encryptionKeyPath' => $config['encryption_key_path'] ?? null, |
||
182 | 'encryptionKey' => $config['encryption_key'] ?? null, |
||
183 | ], |
||
184 | 'azure' => [ |
||
185 | 'clientId' => $config['client_id'], |
||
186 | 'clientSecret' => $config['client_secret'], |
||
187 | 'clientCertificatePrivateKey' => $config['client_certificate_private_key'] ?? null, |
||
188 | 'clientCertificateThumbprint' => $config['client_certificate_thumbprint'] ?? null, |
||
189 | 'urlLogin' => $config['url_login'] ?? null, |
||
190 | 'pathAuthorize' => $config['path_authorize'] ?? null, |
||
191 | 'pathToken' => $config['path_token'] ?? null, |
||
192 | 'scope' => $config['scope'] ?? null, |
||
193 | 'tenant' => $config['tenant'] ?? null, |
||
194 | 'urlAPI' => $config['url_api'] ?? null, |
||
195 | 'resource' => $config['resource'] ?? null, |
||
196 | 'API_VERSION' => $config['api_version'] ?? null, |
||
197 | 'authWithResource' => $config['auth_with_resource'] ?? null, |
||
198 | 'defaultEndPointVersion' => $config['default_end_point_version'] ?? null, |
||
199 | ], |
||
200 | }; |
||
201 | |||
202 | return array_filter($defaults, fn ($value) => null !== $value); |
||
203 | } |
||
228 |