| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 78 | public function getProviderOptions(string $providerType, array $config): array |
||
| 79 | { |
||
| 80 | $defaults = match ($providerType) { |
||
| 81 | 'generic' => [ |
||
| 82 | 'clientId' => $config['client_id'], |
||
| 83 | 'clientSecret' => $config['client_secret'], |
||
| 84 | 'urlAuthorize' => $config['urlAuthorize'], |
||
| 85 | 'urlAccessToken' => $config['urlAccessToken'], |
||
| 86 | 'urlResourceOwnerDetails' => $config['urlResourceOwnerDetails'], |
||
| 87 | 'accessTokenMethod' => $config['accessTokenMethod'] ?? null, |
||
| 88 | 'accessTokenResourceOwnerId' => $config['accessTokenResourceOwnerId'] ?? null, |
||
| 89 | 'scopeSeparator' => $config['scopeSeparator'] ?? null, |
||
| 90 | 'responseError' => $config['responseError'] ?? null, |
||
| 91 | 'responseCode' => $config['responseCode'] ?? null, |
||
| 92 | 'responseResourceOwnerId' => $config['responseResourceOwnerId'] ?? null, |
||
| 93 | 'scopes' => $config['scopes'] ?? null, |
||
| 94 | 'pkceMethod' => $config['pkceMethod'] ?? null, |
||
| 95 | ], |
||
| 96 | 'facebook' => [ |
||
| 97 | 'clientId' => $config['client_id'], |
||
| 98 | 'clientSecret' => $config['client_secret'], |
||
| 99 | 'graphApiVersion' => $config['graph_api_version'] ?? null, |
||
| 100 | ], |
||
| 101 | 'keycloak' => [ |
||
| 102 | 'clientId' => $config['client_id'], |
||
| 103 | 'clientSecret' => $config['client_secret'], |
||
| 104 | 'authServerUrl' => $config['auth_server_url'], |
||
| 105 | 'realm' => $config['realm'], |
||
| 106 | 'version' => $config['version'] ?? null, |
||
| 107 | 'encryptionAlgorithm' => $config['encryption_algorithm'] ?? null, |
||
| 108 | 'encryptionKeyPath' => $config['encryption_key_path'] ?? null, |
||
| 109 | 'encryptionKey' => $config['encryption_key'] ?? null, |
||
| 110 | ], |
||
| 111 | 'azure' => [ |
||
| 112 | 'clientId' => $config['client_id'], |
||
| 113 | 'clientSecret' => $config['client_secret'], |
||
| 114 | 'clientCertificatePrivateKey' => $config['client_certificate_private_key'] ?? null, |
||
| 115 | 'clientCertificateThumbprint' => $config['client_certificate_thumbprint'] ?? null, |
||
| 116 | 'urlLogin' => $config['url_login'] ?? null, |
||
| 117 | 'pathAuthorize' => $config['path_authorize'] ?? null, |
||
| 118 | 'pathToken' => $config['path_token'] ?? null, |
||
| 119 | 'scope' => $config['scope'] ?? null, |
||
| 120 | 'tenant' => $config['tenant'] ?? null, |
||
| 121 | 'urlAPI' => $config['url_api'] ?? null, |
||
| 122 | 'resource' => $config['resource'] ?? null, |
||
| 123 | 'API_VERSION' => $config['api_version'] ?? null, |
||
| 124 | 'authWithResource' => $config['auth_with_resource'] ?? null, |
||
| 125 | 'defaultEndPointVersion' => $config['default_end_point_version'] ?? null, |
||
| 126 | ], |
||
| 127 | }; |
||
| 128 | |||
| 129 | return array_filter($defaults, fn ($value) => null !== $value); |
||
| 130 | } |
||
| 132 |